aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+orbitalquark@users.noreply.github.com>2022-03-17 12:15:18 -0400
committerGravatar mitchell <70453897+orbitalquark@users.noreply.github.com>2022-03-17 12:15:18 -0400
commitf81316624d077360447fd4ba977b7cb22ee2061b (patch)
treea0787e08a3c73d86be844482f98f5ab9097018c6 /test
parent4cdb674929e79104d9f5301656f4169b0fe86f43 (diff)
Fixed "Find Next" for zero-width regex searches.
"Find Prev" still does not work and appears to be a Scintilla bug.
Diffstat (limited to 'test')
-rw-r--r--test/test.lua36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/test.lua b/test/test.lua
index 4c25a598..c3c7a695 100644
--- a/test/test.lua
+++ b/test/test.lua
@@ -2623,6 +2623,42 @@ function test_ui_find_incremental_not_found()
buffer:close(true)
end
+function test_ui_find_find_regex_empty()
+ buffer.new()
+ buffer:set_text('foo\n\n\nfoo')
+ ui.find.regex = true
+ for _, text in ipairs{'^', '$', '^.*$'} do
+ buffer:document_start()
+ ui.find.find_entry_text = text
+ for i = 1, buffer.line_count do
+ ui.find.find_next()
+ assert(buffer:line_from_position(buffer.current_pos), i)
+ if #text == 1 then
+ assert(buffer.selection_empty, 'zero-width find result expected')
+ else
+ assert_equal(buffer:get_sel_text(), buffer:get_line(i):match('^[^\r\n]*'))
+ end
+ end
+ if #text > 1 then
+ ui.find.find_next() -- should wrap
+ assert_equal(buffer:line_from_position(buffer.current_pos), 1)
+ end
+ end
+ ui.find.regex = false
+ buffer:close(true)
+end
+
+function test_ui_find_find_prev_regex_empty()
+ buffer.new()
+ buffer:add_text('foo\n\n\nfoo')
+ ui.find.find_entry_text, ui.find.regex = '$', true
+ ui.find.find_prev()
+ assert_equal(buffer:line_from_position(buffer.current_pos), buffer.line_count - 1)
+ ui.find.regex = false
+ buffer:close(true)
+end
+expected_failure(test_ui_find_find_prev_regex_empty) -- Scintilla bug?
+
function test_ui_find_find_in_files()
ui.find.find_entry_text = 'foo'
ui.find.match_case = true