mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-26 21:00:21 +00:00
console.lua: expand the first completion on Enter
If you run a command without manually selecting a completion, select the first one. e.g. set vo gn runs set vo gpu-next.
This commit is contained in:
committed by
Kacper Michajłow
parent
57a6f12ed3
commit
2f271a92de
@@ -15,7 +15,8 @@ ESC and Ctrl+[
|
||||
Hide the console.
|
||||
|
||||
ENTER, Ctrl+j and Ctrl+m
|
||||
Run the typed command.
|
||||
Expand the first completion suggestion if present and if none was selected,
|
||||
and run the typed command.
|
||||
|
||||
Shift+ENTER
|
||||
Type a literal newline character.
|
||||
|
||||
@@ -106,6 +106,7 @@ local first_match_to_print = 1
|
||||
local default_item
|
||||
|
||||
local complete
|
||||
local cycle_through_suggestions
|
||||
local set_active
|
||||
|
||||
|
||||
@@ -821,6 +822,10 @@ local function handle_enter()
|
||||
mp.commandv('script-message-to', input_caller, 'input-event', 'submit',
|
||||
utils.format_json({line}))
|
||||
else
|
||||
if selected_suggestion_index == 0 then
|
||||
cycle_through_suggestions()
|
||||
end
|
||||
|
||||
-- match "help [<text>]", return <text> or "", strip all whitespace
|
||||
local help = line:match('^%s*help%s+(.-)%s*$') or
|
||||
(line:match('^%s*help$') and '')
|
||||
@@ -1346,7 +1351,7 @@ local function strip_common_characters(str, prefix)
|
||||
max_overlap_length(prefix, str)))
|
||||
end
|
||||
|
||||
local function cycle_through_suggestions(backwards)
|
||||
cycle_through_suggestions = function (backwards)
|
||||
if #suggestion_buffer == 0 then
|
||||
-- Allow Tab completion of commands before typing anything.
|
||||
if line == '' then
|
||||
|
||||
Reference in New Issue
Block a user