bugfix: restart search on backspace

This feels better when I press a few keys, then backspace and press new
keys. It might be confusing if I hit 'down' a few times then backspace,
but I seldom do that.
This commit is contained in:
Kartik K. Agaram 2024-06-23 10:36:53 -07:00
parent a7d42f115b
commit a2f526ad19
1 changed files with 3 additions and 0 deletions

View File

@ -403,6 +403,9 @@ function edit.keychord_press(State, chord, key)
local len = utf8.len(State.search_term)
local byte_offset = Text.offset(State.search_term, len)
State.search_term = string.sub(State.search_term, 1, byte_offset-1)
State.cursor = deepcopy(State.search_backup.cursor)
State.screen_top = deepcopy(State.search_backup.screen_top)
Text.search_next(State)
elseif chord == 'down' then
State.cursor1.pos = State.cursor1.pos+1
Text.search_next(State)