about summary refs log tree commit diff stats
path: root/text_tests.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2023-05-13 17:02:10 -0700
committerKartik K. Agaram <vc@akkartik.com>2023-05-13 17:02:10 -0700
commit8e02c2c0218b4e233f14d130f7d339128886f763 (patch)
tree7cc128ebe9c9ddda77eec2e6f5cd3c22dc591158 /text_tests.lua
parent6a1d8e5164a9bb21c654f4cfa7bc8ff4c43e6c95 (diff)
downloadtext.love-8e02c2c0218b4e233f14d130f7d339128886f763.tar.gz
bugfix: searching files containing unicode
Before this change the cursor was moving, but not being highlighted
properly when the cursor line contained unicode before the cursor.
Diffstat (limited to 'text_tests.lua')
-rw-r--r--text_tests.lua20
1 files changed, 10 insertions, 10 deletions
diff --git a/text_tests.lua b/text_tests.lua
index cfdffdd..8b646a4 100644
--- a/text_tests.lua
+++ b/text_tests.lua
@@ -1985,7 +1985,7 @@ end
 function test_search()
   App.screen.init{width=120, height=60}
   Editor_state = edit.initialize_test_state()
-  Editor_state.lines = load_array{'```lines', '```', 'def', 'ghi', 'deg'}
+  Editor_state.lines = load_array{'```lines', '```', 'def', 'ghi', '’deg'}  -- contains unicode quote in final line
   Text.redraw_all(Editor_state)
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
@@ -2006,15 +2006,15 @@ function test_search()
   edit.run_after_keychord(Editor_state, 'down')
   edit.run_after_keychord(Editor_state, 'return')
   check_eq(Editor_state.cursor1.line, 4, '2/cursor:line')
-  check_eq(Editor_state.cursor1.pos, 1, '2/cursor:pos')
+  check_eq(Editor_state.cursor1.pos, 2, '2/cursor:pos')
 end
 
 function test_search_upwards()
   App.screen.init{width=120, height=60}
   Editor_state = edit.initialize_test_state()
-  Editor_state.lines = load_array{'abc abd'}
+  Editor_state.lines = load_array{'’abc', 'abd'}  -- contains unicode quote
   Text.redraw_all(Editor_state)
-  Editor_state.cursor1 = {line=1, pos=2}
+  Editor_state.cursor1 = {line=2, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
   edit.draw(Editor_state)
@@ -2024,15 +2024,15 @@ function test_search_upwards()
   -- search for previous occurrence
   edit.run_after_keychord(Editor_state, 'up')
   check_eq(Editor_state.cursor1.line, 1, '2/cursor:line')
-  check_eq(Editor_state.cursor1.pos, 1, '2/cursor:pos')
+  check_eq(Editor_state.cursor1.pos, 2, '2/cursor:pos')
 end
 
 function test_search_wrap()
   App.screen.init{width=120, height=60}
   Editor_state = edit.initialize_test_state()
-  Editor_state.lines = load_array{'abc'}
+  Editor_state.lines = load_array{'’abc', 'def'}  -- contains unicode quote in first line
   Text.redraw_all(Editor_state)
-  Editor_state.cursor1 = {line=1, pos=3}
+  Editor_state.cursor1 = {line=2, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
   edit.draw(Editor_state)
@@ -2042,13 +2042,13 @@ function test_search_wrap()
   edit.run_after_keychord(Editor_state, 'return')
   -- cursor wraps
   check_eq(Editor_state.cursor1.line, 1, '1/cursor:line')
-  check_eq(Editor_state.cursor1.pos, 1, '1/cursor:pos')
+  check_eq(Editor_state.cursor1.pos, 2, '1/cursor:pos')
 end
 
 function test_search_wrap_upwards()
   App.screen.init{width=120, height=60}
   Editor_state = edit.initialize_test_state()
-  Editor_state.lines = load_array{'abc abd'}
+  Editor_state.lines = load_array{'abc ’abd'}  -- contains unicode quote
   Text.redraw_all(Editor_state)
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
@@ -2060,5 +2060,5 @@ function test_search_wrap_upwards()
   edit.run_after_keychord(Editor_state, 'up')
   -- cursor wraps
   check_eq(Editor_state.cursor1.line, 1, '1/cursor:line')
-  check_eq(Editor_state.cursor1.pos, 5, '1/cursor:pos')
+  check_eq(Editor_state.cursor1.pos, 6, '1/cursor:pos')
 end