diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2022-07-01 12:16:43 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2022-07-01 12:16:43 -0700 |
commit | 914d9c6f981c1415a389cd87034779da58234bc9 (patch) | |
tree | 6cad8d2cdbe40c7a06e8cbbd94cbfb2994e4d148 | |
parent | 79df3da04be029ee4470638917c1b5f305a6c089 (diff) | |
download | view.love-914d9c6f981c1415a389cd87034779da58234bc9.tar.gz |
bugfix: clicking on empty lines
-rw-r--r-- | main.lua | 3 | ||||
-rw-r--r-- | text_tests.lua | 16 |
2 files changed, 18 insertions, 1 deletions
diff --git a/main.lua b/main.lua index 32b2845..dff23c0 100644 --- a/main.lua +++ b/main.lua @@ -239,7 +239,8 @@ function App.draw() if line_index >= Screen_top1.line then Screen_bottom1.line = line_index if line.mode == 'text' and line.data == '' then - line.y = y + line.starty = y + line.startpos = 1 -- insert new drawing button('draw', {x=4,y=y+4, w=12,h=12, color={1,1,0}, icon = icon.insert_drawing, diff --git a/text_tests.lua b/text_tests.lua index 162f391..025c76b 100644 --- a/text_tests.lua +++ b/text_tests.lua @@ -78,6 +78,22 @@ function test_click_with_mouse() check_eq(Cursor1.line, 1, 'F - test_click_with_mouse/cursor') end +function test_click_with_mouse_on_empty_line() + io.write('\ntest_click_with_mouse_on_empty_line') + -- display two lines with the first one empty + App.screen.init{width=50, height=80} + Lines = load_array{'', 'def'} + Margin_right = 0; Margin_width = Margin_left + Cursor1 = {line=2, pos=1} + Screen_top1 = {line=1, pos=1} + Screen_bottom1 = {} + -- click on the empty line + App.draw() + App.run_after_mouse_click(Margin_left+8,Margin_top+5, 1) + -- cursor moves + check_eq(Cursor1.line, 1, 'F - test_click_with_mouse_on_empty_line/cursor') +end + function test_draw_text() io.write('\ntest_draw_text') App.screen.init{width=120, height=60} |