History

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.

Guido Cella committed 1 year ago

Commit 2f271a91 parent 57a6f122 files · +8 −2Browse files

Unified · Split

2 files
  1. DOCS/man/console.rst +2 −1
  2. player/lua/console.lua +6 −1
DOCS/man/console.rst+2−1
@@ -15,7 +15,8 @@ ESC and Ctrl+[ · 14 unmodified lines
1515 Hide the console.
1616
1717 ENTER, Ctrl+j and Ctrl+m
18− Run the typed command.
18+ Expand the first completion suggestion if present and if none was selected,
19+ and run the typed command.
1920
2021 Shift+ENTER
2122 Type a literal newline character.
player/lua/console.lua+6−1
@@ -106,6 +106,7 @@ local first_match_to_print = 1 · 105 unmodified lines
106106 local default_item
107107
108108 local complete
109+local cycle_through_suggestions
109110 local set_active
110111
111112
@@ -821,6 +822,10 @@ local function handle_enter() · 709 unmodified lines
821822 mp.commandv('script-message-to', input_caller, 'input-event', 'submit',
822823 utils.format_json({line}))
823824 else
825+ if selected_suggestion_index == 0 then
826+ cycle_through_suggestions()
827+ end
828+
824829 -- match "help [<text>]", return <text> or "", strip all whitespace
825830 local help = line:match('^%s*help%s+(.-)%s*$') or
826831 (line:match('^%s*help$') and '')
@@ -1346,7 +1351,7 @@ local function strip_common_characters(str, prefix) · 519 unmodified lines
13461351 max_overlap_length(prefix, str)))
13471352 end
13481353
1349−local function cycle_through_suggestions(backwards)
1354+cycle_through_suggestions = function (backwards)
13501355 if #suggestion_buffer == 0 then
13511356 -- Allow Tab completion of commands before typing anything.
13521357 if line == '' then

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t