diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2023-01-31 22:39:04 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2023-01-31 22:39:04 -0800 |
commit | 33ad6b7e5b5436d9b3e2ddd7119052bf3af5f02f (patch) | |
tree | 8c1744a0346834bc9d86761df3a49ee5c65a3552 /text_tests.lua | |
parent | 266de35f87161f841c26ab18a044cdf0a02682ad (diff) | |
download | view.love-33ad6b7e5b5436d9b3e2ddd7119052bf3af5f02f.tar.gz |
bugfix: up arrow when line above is a drawing
This bug was introduced in commit 528c64d690 on 2022-09-05 :/
Diffstat (limited to 'text_tests.lua')
-rw-r--r-- | text_tests.lua | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/text_tests.lua b/text_tests.lua index 0384b0b..d08848a 100644 --- a/text_tests.lua +++ b/text_tests.lua @@ -1055,6 +1055,31 @@ function test_down_arrow_moves_cursor() App.screen.check(y, 'ghi', 'screen:3') end +function test_down_arrow_skips_drawing() + -- some lines of text with a drawing intermixed + local drawing_width = 50 + App.screen.init{width=Editor_state.left+drawing_width, height=100} + Editor_state = edit.initialize_test_state() + Editor_state.lines = load_array{'abc', -- height 15 + '```lines', '```', -- height 25 + 'ghi'} + Text.redraw_all(Editor_state) + Editor_state.cursor1 = {line=1, pos=1} + Editor_state.screen_top1 = {line=1, pos=1} + Editor_state.screen_bottom1 = {} + edit.draw(Editor_state) + local y = Editor_state.top + App.screen.check(y, 'abc', 'baseline/screen:1') + y = y + Editor_state.line_height + local drawing_height = Drawing_padding_height + drawing_width/2 -- default + y = y + drawing_height + App.screen.check(y, 'ghi', 'baseline/screen:3') + check(Editor_state.cursor_x, 'baseline/cursor_x') + -- after hitting the down arrow the cursor moves down by 2 lines, skipping the drawing + edit.run_after_keychord(Editor_state, 'down') + check_eq(Editor_state.cursor1.line, 3, 'cursor') +end + function test_down_arrow_scrolls_down_by_one_line() -- display the first three lines with the cursor on the bottom line App.screen.init{width=120, height=60} @@ -1203,6 +1228,31 @@ function test_up_arrow_moves_cursor() App.screen.check(y, 'ghi', 'screen:3') end +function test_up_arrow_skips_drawing() + -- some lines of text with a drawing intermixed + local drawing_width = 50 + App.screen.init{width=Editor_state.left+drawing_width, height=100} + Editor_state = edit.initialize_test_state() + Editor_state.lines = load_array{'abc', -- height 15 + '```lines', '```', -- height 25 + 'ghi'} + Text.redraw_all(Editor_state) + Editor_state.cursor1 = {line=3, pos=1} + Editor_state.screen_top1 = {line=1, pos=1} + Editor_state.screen_bottom1 = {} + edit.draw(Editor_state) + local y = Editor_state.top + App.screen.check(y, 'abc', 'baseline/screen:1') + y = y + Editor_state.line_height + local drawing_height = Drawing_padding_height + drawing_width/2 -- default + y = y + drawing_height + App.screen.check(y, 'ghi', 'baseline/screen:3') + check(Editor_state.cursor_x, 'baseline/cursor_x') + -- after hitting the up arrow the cursor moves up by 2 lines, skipping the drawing + edit.run_after_keychord(Editor_state, 'up') + check_eq(Editor_state.cursor1.line, 1, 'cursor') +end + function test_up_arrow_scrolls_up_by_one_line() -- display the lines 2/3/4 with the cursor on line 2 App.screen.init{width=120, height=60} |