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-08-11 20:14:21 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-08-11 22:23:16 -0700
commite85a7e73d0f4992b775d1848f7343e5da6b225bd (patch)
tree24d825c2a18b4e471dd3d219f8c3f26300eb2609 /text_tests.lua
parent0afd03e72128f691d702ec67f317e6fbf407724e (diff)
downloadtext.love-e85a7e73d0f4992b775d1848f7343e5da6b225bd.tar.gz
bugfix: search upwards
Diffstat (limited to 'text_tests.lua')
-rw-r--r--text_tests.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/text_tests.lua b/text_tests.lua
index 1167355..a37739d 100644
--- a/text_tests.lua
+++ b/text_tests.lua
@@ -2046,6 +2046,25 @@ function test_search()
   check_eq(Editor_state.cursor1.pos, 1, 'F - test_search/2/cursor:pos')
 end
 
+function test_search_upwards()
+  io.write('\ntest_search_upwards')
+  App.screen.init{width=120, height=60}
+  Editor_state = edit.initialize_test_state()
+  Editor_state.lines = load_array{'abc abd'}
+  Text.redraw_all(Editor_state)
+  Editor_state.cursor1 = {line=1, pos=2}
+  Editor_state.screen_top1 = {line=1, pos=1}
+  Editor_state.screen_bottom1 = {}
+  edit.draw(Editor_state)
+  -- search for a string
+  edit.run_after_keychord(Editor_state, 'C-f')
+  edit.run_after_textinput(Editor_state, 'a')
+  -- search for previous occurrence
+  edit.run_after_keychord(Editor_state, 'up')
+  check_eq(Editor_state.cursor1.line, 1, 'F - test_search_upwards/2/cursor:line')
+  check_eq(Editor_state.cursor1.pos, 1, 'F - test_search_upwards/2/cursor:pos')
+end
+
 function test_search_wrap()
   io.write('\ntest_search_wrap')
   App.screen.init{width=120, height=60}