diff options
author | Guido Cella <guido@guidocella.xyz> | 2023-12-09 22:01:57 +0100 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-12-15 15:45:11 +0000 |
commit | 8ceaec174237bb033ec1ea599beeda9fbd373c2e (patch) | |
tree | db92a1fa2c0fb7559a36b732c406446220c159e2 /player/lua | |
parent | 86c8ef5c1f78b6a618dbd2df59aa2d9f2ece6e32 (diff) | |
download | mpv-8ceaec174237bb033ec1ea599beeda9fbd373c2e.tar.bz2 mpv-8ceaec174237bb033ec1ea599beeda9fbd373c2e.tar.xz |
console.lua: clear the suggestions when you move the cursor
Clear completion suggestions from functions that move the cursor, so
that you can't insert suggestions at the wrong spot by pressing Tab
again after moving the cursor,
Also clear suggestions from some editing functions that were never
updated. It is not actually necessary to clear suggestions from
functions that remove text in front of the cursor, but since
handle_del() already clears them, let's just clear them everywhere.
Diffstat (limited to 'player/lua')
-rw-r--r-- | player/lua/console.lua | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/player/lua/console.lua b/player/lua/console.lua index ca065b853e..b4e722105f 100644 --- a/player/lua/console.lua +++ b/player/lua/console.lua @@ -550,12 +550,14 @@ end -- Move the cursor to the next character (Right) function next_char(amount) cursor = next_utf8(line, cursor) + suggestion_buffer = {} update() end -- Move the cursor to the previous character (Left) function prev_char(amount) cursor = prev_utf8(line, cursor) + suggestion_buffer = {} update() end @@ -690,6 +692,7 @@ function go_history(new_pos) end cursor = line:len() + 1 insert_mode = false + suggestion_buffer = {} update() end @@ -715,6 +718,7 @@ function prev_word() -- string in order to do a "backwards" find. This wouldn't be as annoying -- to do if Lua didn't insist on 1-based indexing. cursor = line:len() - select(2, line:reverse():find('%s*[^%s]*', line:len() - cursor + 2)) + 1 + suggestion_buffer = {} update() end @@ -722,6 +726,7 @@ end -- the next word. (Ctrl+Right) function next_word() cursor = select(2, line:find('%s*[^%s]*', cursor)) + 1 + suggestion_buffer = {} update() end @@ -1083,12 +1088,14 @@ end -- Move the cursor to the beginning of the line (HOME) function go_home() cursor = 1 + suggestion_buffer = {} update() end -- Move the cursor to the end of the line (END) function go_end() cursor = line:len() + 1 + suggestion_buffer = {} update() end @@ -1100,6 +1107,7 @@ function del_word() before_cur = before_cur:gsub('[^%s]+%s*$', '', 1) line = before_cur .. after_cur cursor = before_cur:len() + 1 + suggestion_buffer = {} update() end @@ -1112,12 +1120,14 @@ function del_next_word() after_cur = after_cur:gsub('^%s*[^%s]+', '', 1) line = before_cur .. after_cur + suggestion_buffer = {} update() end -- Delete from the cursor to the end of the line (Ctrl+K) function del_to_eol() line = line:sub(1, cursor - 1) + suggestion_buffer = {} update() end @@ -1125,6 +1135,7 @@ end function del_to_start() line = line:sub(cursor) cursor = 1 + suggestion_buffer = {} update() end @@ -1197,6 +1208,7 @@ function paste(clip) local after_cur = line:sub(cursor) line = before_cur .. text .. after_cur cursor = cursor + text:len() + suggestion_buffer = {} update() end |