get rid of an assertion

It's easy for cursor to go off viewport, and that seems fine. Just don't
let a cursor off screen receive keys.
This commit is contained in:
Kartik K. Agaram 2023-11-20 10:26:14 -08:00
parent 5133d7c11f
commit b0670b84ff
4 changed files with 8 additions and 4 deletions

View File

@ -5,7 +5,8 @@ on.keychord_press = function(chord, key)
update_font_settings(Current_pane.editor_state.font_height-2)
elseif chord == 'C-0' then
update_font_settings(20)
else
elseif Current_pane.editor_state.cursor_x then
-- send keys to editor if cursor is visible
edit.keychord_press(Current_pane.editor_state, chord, key)
end
end

View File

@ -1,3 +1,5 @@
on.text_input = function(t)
if Current_pane.editor_state.cursor_x then
edit.text_input(Current_pane.editor_state, t)
end
end

View File

@ -1,3 +1,5 @@
on.key_release = function(key, scancode)
if Current_pane.editor_state.cursor_x then
edit.key_release(Current_pane.editor_state, key, scancode)
end
end

View File

@ -109,7 +109,6 @@ end
-- return y drawn until
function edit.draw(State, fg, hide_cursor, show_line_numbers)
assert(#State.lines == #State.line_cache, ('line_cache is out of date; %d elements when it should be %d'):format(#State.line_cache, #State.lines))
assert(Text.le1(State.screen_top1, State.cursor1), ('screen_top (line=%d,pos=%d) is below cursor (line=%d,pos=%d)'):format(State.screen_top1.line, State.screen_top1.pos, State.cursor1.line, State.cursor1.pos))
State.cursor_x = nil
State.cursor_y = nil
local y = State.top