aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/textadept/find.lua1
-rw-r--r--test/test.lua16
2 files changed, 15 insertions, 2 deletions
diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua
index 231159e2..e1e18e8e 100644
--- a/modules/textadept/find.lua
+++ b/modules/textadept/find.lua
@@ -204,6 +204,7 @@ local function find(text, next, flags, no_wrap, wrapped)
view:vertical_center_caret()
-- Track find text and found text for "replace all" and incremental find.
find_text, found_text = text, buffer:get_sel_text()
+ repl_text = ui.find.replace_entry_text -- save for ui.find.focus()
-- If nothing was found, wrap the search.
if pos == -1 and not no_wrap then
diff --git a/test/test.lua b/test/test.lua
index 001124e4..c4693ea3 100644
--- a/test/test.lua
+++ b/test/test.lua
@@ -1019,14 +1019,12 @@ function test_ui_buffer_switch_save_restore_properties()
buffer:goto_pos(10)
view:fold_line(
buffer:line_from_position(buffer.current_pos), view.FOLDACTION_CONTRACT)
- view.view_eol = true
view.margin_width_n[1] = 0 -- hide line numbers
view:goto_buffer(-1)
assert(view.margin_width_n[1] > 0, 'line numbers are still hidden')
view:goto_buffer(1)
assert_equal(buffer.current_pos, 10)
assert_equal(view.fold_expanded[buffer:line_from_position(buffer.current_pos)], false)
- assert_equal(view.view_eol, true)
assert_equal(view.margin_width_n[1], 0)
buffer:close()
end
@@ -2389,6 +2387,20 @@ function test_ui_find_replace()
buffer:close(true)
end
+function test_ui_find_replace_text_save_restore()
+ if CURSES then return end -- there are focus issues in curses
+ ui.find.focus()
+ ui.find.find_entry_text = 'foo'
+ ui.find.replace_entry_text = 'bar'
+ ui.find.find_next()
+ ui.find.focus() -- simulate activating "Find"
+ assert_equal(ui.find.replace_entry_text, 'bar')
+ ui.find.focus{in_files = true} -- simulate activating "Find in Files"
+ assert(ui.find.replace_entry_text ~= 'bar', 'filter entry text not set')
+ ui.find.focus{in_files = false} -- simulate activating "Find"
+ assert_equal(ui.find.replace_entry_text, 'bar')
+end
+
function test_ui_find_replace_all()
buffer.new()
local text = table.concat({