Skip to content

Commit 4e8d95e

Browse files
committed
fix: undo and default prompt value
1 parent 72c6315 commit 4e8d95e

File tree

6 files changed

+9
-10
lines changed

6 files changed

+9
-10
lines changed

doc/search-and-replace.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Default values:
3535
-- When `false`, the mapping is not created.
3636
---@type string
3737
replace_by_reference = "<Leader>rr",
38-
-- Sets a global mapping to Neovim, which will trigger the "undo" function.
38+
-- Sets a global mapping to Neovim, which will trigger the "undo" function for the last `replace_by_*` operation.
3939
-- When `false`, the mapping is not created.
4040
---@type string
4141
replace_undo = "<Leader>ru",

lua/search-and-replace/config.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ SearchAndReplace.options = {
3232
-- When `false`, the mapping is not created.
3333
---@type string
3434
replace_by_reference = "<Leader>rr",
35-
-- Sets a global mapping to Neovim, which will trigger the "undo" function.
35+
-- Sets a global mapping to Neovim, which will trigger the "undo" function for the last `replace_by_*` operation.
3636
-- When `false`, the mapping is not created.
3737
---@type string
3838
replace_undo = "<Leader>ru",

lua/search-and-replace/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function SearchAndReplace.replace_by_references()
1616
end
1717

1818
function SearchAndReplace.replace_undo()
19-
main.undo("replace undo")
19+
main.replace_undo("replace undo")
2020
end
2121

2222
function SearchAndReplace.setup(opts)

lua/search-and-replace/main.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function main.search_and_replace_by_pattern(scope)
2020
end
2121
end)
2222

23-
state.create_window(state, scope)
23+
state.create_windfooow(state, scope)
2424
end
2525

2626
--- Replaces the word under cursor or current visual selection in the current project.
@@ -38,7 +38,7 @@ function main.replace_by_pattern(scope)
3838
end
3939
end)
4040

41-
state.create_window(state, scope)
41+
state.create_windfooow(state, scope)
4242
end
4343

4444
--- Replaces the word under cursor or current visual selection using vim.lsp.buf.references().
@@ -62,7 +62,7 @@ function main.replace_by_references(scope)
6262
end, 500)
6363
end)
6464

65-
state.create_window(state, scope)
65+
state.create_windfooow(state, scope)
6666
end
6767

6868
--- Restores the backup files of the last `replace_*` operation.

lua/search-and-replace/state.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ function state:create_buffer(scope, cb)
147147
_G.SearchAndReplace.config.default_replace_prompt_to_selection
148148
and self.selection ~= ""
149149
then
150-
vim.fn.prompt_setprompt(self.buffer, self.selection)
151-
-- vim.api.nvim_buf_set_text(self.buffer, 0, 0, 0, 0, { self.selection })
150+
vim.api.nvim_buf_set_lines(self.buffer, 0, -1, false, { "> " .. self.selection })
152151
end
153152
end,
154153
group = self.augroup_name,
@@ -172,7 +171,7 @@ end
172171
---
173172
--- @param scope string
174173
---@private
175-
function state:create_window(scope)
174+
function state:create_windfooow(scope)
176175
self.window = vim.api.nvim_open_win(self.buffer, true, {
177176
style = "minimal",
178177
relative = "editor",

plugin/search-and-replace.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ vim.api.nvim_create_user_command("ReplaceByReferences", function()
1414
end, { range = true })
1515

1616
vim.api.nvim_create_user_command("ReplaceUndo", function()
17-
require("search-and-replace").undo()
17+
require("search-and-replace").replace_undo()
1818
end, {})

0 commit comments

Comments
 (0)