Use hidden suggestions also for replace dialog

This commit is contained in:
Francesco Abbate 2021-09-07 18:08:54 +02:00 committed by Francesco
parent 4bcc1cc07c
commit fa8b3b33b1
2 changed files with 6 additions and 2 deletions

View File

@ -78,19 +78,22 @@ local function replace(kind, default, fn)
core.command_view:set_text(default, true)
core.status_view:show_tooltip(get_find_tooltip())
core.command_view:set_hidden_suggestions()
core.command_view:enter("Find To Replace " .. kind, function(old)
core.command_view:set_text(old, true)
local s = string.format("Replace %s %q With", kind, old)
core.command_view:set_hidden_suggestions()
core.command_view:enter(s, function(new)
table.insert(core.previous_replace, new)
local n = doc():replace(function(text)
return fn(text, old, new)
end)
core.log("Replaced %d instance(s) of %s %q with %q", n, kind, old, new)
end, function() end, function()
end, function() return core.previous_replace end, function()
core.status_view:remove_tooltip()
end)
end, function() end, function()
end, function() return core.previous_find end, function()
core.status_view:remove_tooltip()
end)
end

View File

@ -497,6 +497,7 @@ function core.init()
core.redraw = true
core.visited_files = {}
core.previous_find = {}
core.previous_replace = {}
core.restart_request = false
core.quit_request = false
core.replacements = whitespace_replacements()