diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2024-10-29 15:43:35 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2024-10-29 15:58:00 -0700 |
commit | c1a3616964bfdeb11144c0e7289fc16ba563e84a (patch) | |
tree | 18a6b93c13b61070de189527a4357bfb4c2d9893 /text_tests.lua | |
parent | 1609d79516b2e8f790648fd67614d9edb9c2e24c (diff) | |
download | view.love-c1a3616964bfdeb11144c0e7289fc16ba563e84a.tar.gz |
bugfix in search UI
This one is ancient and it affects every single one of my forks, including the whole lines2 lineage. The corner case: searching for empty string. In the process I've also cleaned up edit.check_locs on initialization to only modify cursor if it can find a legal place for it. In general I should be more careful about mutating the cursor. Just adding 1 to it is irresponsible.
Diffstat (limited to 'text_tests.lua')
-rw-r--r-- | text_tests.lua | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/text_tests.lua b/text_tests.lua index 9b34a24..aebade8 100644 --- a/text_tests.lua +++ b/text_tests.lua @@ -2073,3 +2073,17 @@ function test_search_wrap_upwards() check_eq(Editor_state.cursor1.line, 1, '1/cursor:line') check_eq(Editor_state.cursor1.pos, 6, '1/cursor:pos') end + +function test_search_downwards_from_end_of_line() + App.screen.init{width=120, height=60} + Editor_state = edit.initialize_test_state() + Editor_state.lines = load_array{'abc', 'def', 'ghi'} + Text.redraw_all(Editor_state) + Editor_state.cursor1 = {line=1, pos=4} + Editor_state.screen_top1 = {line=1, pos=1} + edit.draw(Editor_state) + -- search for empty string + edit.run_after_keychord(Editor_state, 'C-f', 'f') + edit.run_after_keychord(Editor_state, 'down', 'down') + -- no crash +end |