Skip to content

Commit

Permalink
console.lua: complete multiple flags separated by +
Browse files Browse the repository at this point in the history
  • Loading branch information
guidocella authored and kasper93 committed Feb 24, 2025
1 parent 72bb227 commit d4dc19a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions player/lua/console.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1586,6 +1586,24 @@ local function command_flags_at_2nd_argument_list(command)
return flags[command]
end

local function handle_flags(command, arg_index, flags)
for _, cmd in pairs(mp.get_property_native('command-list')) do
if cmd.name == command then
if cmd.args[arg_index] and cmd.args[arg_index].type == 'Flags' then
break
else
return
end
end
end

local plus_pos = flags:find('%+[^%+]*$')

if plus_pos then
completion_pos = completion_pos + plus_pos
end
end

local function list_executables()
local executable_map = {}
local path = os.getenv('PATH') or ''
Expand Down Expand Up @@ -1801,6 +1819,7 @@ complete = function ()
completions = handle_file_completion(before_cur)
else
completions = command_flags_at_1st_argument_list(first_useful_token.text)
handle_flags(first_useful_token.text, 1, tokens[#tokens].text)
end
elseif first_useful_token.text == 'cycle-values' then
completions = handle_choice_completion(tokens[first_useful_token_index + 1].text,
Expand All @@ -1820,6 +1839,7 @@ complete = function ()
end
else
completions = command_flags_at_2nd_argument_list(first_useful_token.text)
handle_flags(first_useful_token.text, 2, tokens[#tokens].text)
end
elseif #tokens == first_useful_token_index + 3 then
if first_useful_token.text == 'change-list' then
Expand Down

0 comments on commit d4dc19a

Please sign in to comment.