about summary refs log tree commit diff stats
path: root/text_tests.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-06-05 08:29:38 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-05 08:29:38 -0700
commitde473046bc6ad8b33e57399e662b271cd2f8cc44 (patch)
treed693df8fdaf802f3030233d9ee789f61bcdb2d94 /text_tests.lua
parent5055361209da2dc9427ffafe09c4d29933a94747 (diff)
downloadlines.love-de473046bc6ad8b33e57399e662b271cd2f8cc44.tar.gz
check for scroll when just typing
Diffstat (limited to 'text_tests.lua')
-rw-r--r--text_tests.lua35
1 files changed, 33 insertions, 2 deletions
diff --git a/text_tests.lua b/text_tests.lua
index 6982c04..c11ef6e 100644
--- a/text_tests.lua
+++ b/text_tests.lua
@@ -78,12 +78,11 @@ function test_edit_wrapping_text()
   Cursor1 = {line=2, pos=4}
   Screen_top1 = {line=1, pos=1}
   Screen_bottom1 = {}
+  App.draw()
   App.run_after_textinput('g')
   App.run_after_textinput('h')
   App.run_after_textinput('i')
   App.run_after_textinput('j')
-  App.run_after_textinput('k')
-  App.run_after_textinput('l')
   local y = Margin_top
   App.screen.check(y, 'abc', 'F - test_edit_wrapping_text/screen:1')
   y = y + Line_height
@@ -727,6 +726,37 @@ function test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom()
   App.screen.check(y, 'kl', 'F - test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom/screen:2')
 end
 
+function test_typing_on_bottom_line_scrolls_down()
+  io.write('\ntest_typing_on_bottom_line_scrolls_down')
+  -- display a few lines with cursor on bottom line
+  App.screen.init{width=25+30, height=60}
+  Lines = load_array{'abc', 'def', 'ghi', 'jkl'}
+  Line_width = App.screen.width
+  Cursor1 = {line=3, pos=4}
+  Screen_top1 = {line=1, pos=1}
+  Screen_bottom1 = {}
+  App.draw()
+  local y = Margin_top
+  App.screen.check(y, 'abc', 'F - test_typing_on_bottom_line_scrolls_down/baseline/screen:1')
+  y = y + Line_height
+  App.screen.check(y, 'def', 'F - test_typing_on_bottom_line_scrolls_down/baseline/screen:2')
+  y = y + Line_height
+  App.screen.check(y, 'ghi', 'F - test_typing_on_bottom_line_scrolls_down/baseline/screen:3')
+  -- after typing something the line wraps and the screen scrolls down
+  App.run_after_textinput('j')
+  App.run_after_textinput('k')
+  App.run_after_textinput('l')
+  check_eq(Screen_top1.line, 2, 'F - test_typing_on_bottom_line_scrolls_down/screen_top')
+  check_eq(Cursor1.line, 3, 'F - test_typing_on_bottom_line_scrolls_down/cursor:line')
+  check_eq(Cursor1.pos, 7, 'F - test_typing_on_bottom_line_scrolls_down/cursor:pos')
+  y = Margin_top
+  App.screen.check(y, 'def', 'F - test_typing_on_bottom_line_scrolls_down/screen:1')
+  y = y + Line_height
+  App.screen.check(y, 'ghijk', 'F - test_typing_on_bottom_line_scrolls_down/screen:2')
+  y = y + Line_height
+  App.screen.check(y, 'l', 'F - test_typing_on_bottom_line_scrolls_down/screen:3')
+end
+
 function test_position_cursor_on_recently_edited_wrapping_line()
   -- draw a line wrapping over 2 screen lines
   io.write('\ntest_position_cursor_on_recently_edited_wrapping_line')
@@ -924,6 +954,7 @@ function test_undo_insert_text()
   Screen_top1 = {line=1, pos=1}
   Screen_bottom1 = {}
   -- insert a character
+  App.draw()
   App.run_after_textinput('g')
   check_eq(Cursor1.line, 2, 'F - test_undo_insert_text/baseline/cursor:line')
   check_eq(Cursor1.pos, 5, 'F - test_undo_insert_text/baseline/cursor:pos')