diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2022-06-30 18:00:09 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2022-06-30 18:14:48 -0700 |
commit | 510b0d1dc378f87517e17bfe1961fbefeb58d033 (patch) | |
tree | bfc1d21c01eb8579c2d2ce262c1c47f16684fc56 /text_tests.lua | |
parent | 98fa46bf990352a3451a6a82489dcc61caf6c6a5 (diff) | |
download | lines.love-510b0d1dc378f87517e17bfe1961fbefeb58d033.tar.gz |
bugfix: lines that aren't drawn from the start
I can't believe I didn't catch this until now. All I had to do is open MobyDick.markdown from https://www.hogbaysoftware.com/posts/moby-dick-workout, press page-down and click on the top screen line (or any screen line containing the same line as the top screen line). Easy to catch with any file containing lots of overly long lines, as happens in particular at the start of Moby Dick. I _had_ seen this problem before, but it seemed to disappear after unrelated changes, and I convinced myself I'd fixed it as a side-effect. The bug just failed to manifest if the top line happened to start at the top of the screen. Scroll down a few pages in Moby Dick and the dialogue starts and line length drops precipitously.
Diffstat (limited to 'text_tests.lua')
-rw-r--r-- | text_tests.lua | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/text_tests.lua b/text_tests.lua index 2a6c45d..5c21038 100644 --- a/text_tests.lua +++ b/text_tests.lua @@ -184,6 +184,27 @@ function test_click_on_wrapping_line() check_eq(Cursor1.pos, 13, 'F - test_click_on_wrapping_line/cursor:pos') end +function test_click_on_wrapping_line_rendered_from_partway_at_top_of_screen() + io.write('\ntest_click_on_wrapping_line_rendered_from_partway_at_top_of_screen') + -- display a wrapping line from its second screen line + App.screen.init{width=80, height=80} + -- 12345678901234 + Lines = load_array{"madam I'm adam"} + Line_width = 75 + Cursor1 = {line=1, pos=8} + Screen_top1 = {line=1, pos=7} + Screen_bottom1 = {} + App.draw() + local y = Margin_top + App.screen.check(y, "I'm ada", 'F - test_click_on_wrapping_line_rendered_from_partway_at_top_of_screen/baseline/screen:2') + y = y + Line_height + -- click past end of second screen line + App.run_after_mouse_click(App.screen.width-2,y-2, 1) + -- cursor moves to end of screen line + check_eq(Cursor1.line, 1, 'F - test_click_on_wrapping_line_rendered_from_partway_at_top_of_screen/cursor:line') + check_eq(Cursor1.pos, 13, 'F - test_click_on_wrapping_line_rendered_from_partway_at_top_of_screen/cursor:pos') +end + function test_click_past_end_of_wrapping_line() io.write('\ntest_click_past_end_of_wrapping_line') -- display a wrapping line |