correct bugfix for mouse wheel

Sequence of events in previous scenario:
1. car.draw throws an error
2. The wrapping call_protected invokes send_errors_to_output
3. send_errors_to_output uses Text.insert_text, which was extracted from
   the paste implementation on Nov 20. But it doesn't scroll, and so the
   cursor is off screen.
4. Drawing frames never sets cursor_x or cursor_y.
5. Mouse wheel indirectly requires them to be set. Boom.
This commit is contained in:
Kartik K. Agaram 2023-12-17 13:56:26 -08:00
parent bab5b7c37c
commit 43f9984e22
1 changed files with 3 additions and 4 deletions

View File

@ -259,7 +259,6 @@ function edit.mouse_wheel_move(State, dx,dy)
end
elseif dy < 0 then
State.cursor1 = {line=State.screen_bottom1.line, pos=State.screen_bottom1.pos}
State.cursor_x = 0
for i=1,math.floor(-dy) do
Text.down(State)
end
@ -373,9 +372,6 @@ function edit.keychord_press(State, chord, key, readonly)
local before = snapshot(State, before_line)
local clipboard_data = App.get_clipboard()
Text.insert_text(State, clipboard_data)
if Text.cursor_out_of_screen(State) then
Text.snap_cursor_to_bottom_of_screen(State, State.left, State.right)
end
schedule_save(State)
record_undo_event(State, {before=before, after=snapshot(State, before_line, State.cursor1.line)})
-- dispatch to text
@ -394,6 +390,9 @@ function Text.insert_text(State, d)
Text.insert_at_cursor(State, c)
end
end
if Text.cursor_out_of_screen(State) then
Text.snap_cursor_to_bottom_of_screen(State, State.left, State.right)
end
end
function edit.clear(State)