aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+orbitalquark@users.noreply.github.com>2021-06-11 14:33:53 -0400
committerGravatar mitchell <70453897+orbitalquark@users.noreply.github.com>2021-06-11 14:33:53 -0400
commitc8d40c1af58d8b21bb99e850aa6e7ded61dd7275 (patch)
tree813784d50ae96ff8850c0ae2972b128e91e07b17 /test
parent48134170e780091b753d11dd945547a719719dd3 (diff)
Support "Replace All" in multiple and rectangular selection.
Diffstat (limited to 'test')
-rw-r--r--test/test.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/test.lua b/test/test.lua
index 3850da0d..05084c20 100644
--- a/test/test.lua
+++ b/test/test.lua
@@ -2715,6 +2715,8 @@ function test_ui_find_replace_all()
ui.find.find_entry_text, ui.find.replace_entry_text = 'f(.)\\1', 'b\\1\\1'
ui.find.replace_all() -- replace in selection
assert_equal(buffer:get_text(), 'foo\nboobar\nboobaz\nboofoo')
+ assert_equal(buffer.selection_start, buffer:position_from_line(2))
+ assert_equal(buffer.selection_end, buffer:position_from_line(4) + 3)
ui.find.regex = false
buffer:undo()
ui.find.find_entry_text, ui.find.replace_entry_text = 'foo', ''
@@ -2723,6 +2725,17 @@ function test_ui_find_replace_all()
ui.find.find_entry_text, ui.find.replace_entry_text = 'quux', ''
ui.find.replace_all()
assert_equal(buffer:get_text(), '\nbar\nbaz\n')
+ buffer:undo()
+ buffer:set_selection(1, 4)
+ buffer:add_selection(buffer:position_from_line(3), buffer:position_from_line(3) + 3)
+ ui.find.find_entry_text, ui.find.replace_entry_text = 'foo', 'quux'
+ ui.find.replace_all() -- replace in multiple selection
+ assert_equal(buffer:get_text(), 'quux\nfoobar\nquuxbaz\nfoofoo')
+ assert_equal(buffer.selections, 2)
+ assert_equal(buffer.selection_n_start[1], 1)
+ assert_equal(buffer.selection_n_end[1], 5)
+ assert_equal(buffer.selection_n_start[2], buffer:position_from_line(3))
+ assert_equal(buffer.selection_n_end[2], buffer:position_from_line(3) + 4)
ui.find.find_entry_text, ui.find.replace_entry_text = '', ''
buffer:close(true)
end