aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/test.lua
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+orbitalquark@users.noreply.github.com>2021-06-05 13:37:34 -0400
committerGravatar mitchell <70453897+orbitalquark@users.noreply.github.com>2021-06-05 13:37:34 -0400
commit57d946f2eba8de5f7386b553558567b470900322 (patch)
tree379f1d35b7e170b33b47d5dcc5b3a0f1819adf61 /test/test.lua
parentcb080a63dc6855409300b02195a9d154845ca66d (diff)
Allow "Replace All" for empty regex matches.
Diffstat (limited to 'test/test.lua')
-rw-r--r--test/test.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/test.lua b/test/test.lua
index 09caf59e..0ca00440 100644
--- a/test/test.lua
+++ b/test/test.lua
@@ -2703,6 +2703,26 @@ function test_ui_find_replace_all()
buffer:close(true)
end
+function test_find_replace_all_empty_matches()
+ buffer.new()
+ buffer:set_text('1\n2\n3\n4')
+ ui.find.find_entry_text, ui.find.replace_entry_text = '$', ','
+ ui.find.regex = true
+ ui.find.replace_all()
+ assert_equal(buffer:get_text(), '1,\n2,\n3,\n4,')
+ buffer:undo()
+ buffer:set_sel(buffer:position_from_line(2), buffer:position_from_line(4))
+ ui.find.replace_all()
+ assert_equal(buffer:get_text(), '1\n2,\n3,\n4')
+ buffer:undo()
+ ui.find.find_entry_text, ui.find.replace_entry_text = '^', '$'
+ ui.find.replace_all()
+ assert_equal(buffer:get_text(), '$1\n$2\n$3\n$4')
+ ui.find.find_entry_text, ui.find.replace_entry_text = '', ''
+ ui.find.regex = false
+ buffer:close(true)
+end
+
function test_find_replace_regex_transforms()
buffer.new()
buffer:set_text('foObaRbaz')