bugfix: pagedown was sometimes bouncing up

This commit is contained in:
Kartik K. Agaram 2022-08-10 22:56:10 -07:00
parent ba48aadaa7
commit da34fabf72
2 changed files with 18 additions and 1 deletions

View File

@ -17,7 +17,7 @@ function Text.draw(State, line_index, y, startpos)
-- wrap long lines
local x = State.left
local pos = 1
local screen_line_starting_pos = 1
local screen_line_starting_pos = State.screen_top1.pos
if line_cache.fragments == nil then
Text.compute_fragments(State, line_index)
end

View File

@ -1084,6 +1084,23 @@ function test_pagedown_can_start_from_middle_of_long_wrapping_line()
App.screen.check(y, 'mno ', 'F - test_pagedown_can_start_from_middle_of_long_wrapping_line/screen:3')
end
function test_pagedown_never_moves_up()
io.write('\ntest_pagedown_never_moves_up')
-- draw the final screen line of a wrapping line
App.screen.init{width=Editor_state.left+30, height=60}
Editor_state = edit.initialize_test_state()
Editor_state.lines = load_array{'abc def ghi'}
Text.redraw_all(Editor_state)
Editor_state.cursor1 = {line=1, pos=9}
Editor_state.screen_top1 = {line=1, pos=9}
Editor_state.screen_bottom1 = {}
edit.draw(Editor_state)
-- pagedown makes no change
edit.run_after_keychord(Editor_state, 'pagedown')
check_eq(Editor_state.screen_top1.line, 1, 'F - test_pagedown_never_moves_up/screen_top:line')
check_eq(Editor_state.screen_top1.pos, 9, 'F - test_pagedown_never_moves_up/screen_top:pos')
end
function test_down_arrow_moves_cursor()
io.write('\ntest_down_arrow_moves_cursor')
App.screen.init{width=120, height=60}