Skip to content

Commit 0430cdf

Browse files
committed
fix: no early return in mapping create
1 parent f1473c6 commit 0430cdf

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

lua/search-and-replace/config.lua

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,11 @@ local function register_mappings(options, mappings)
7474

7575
for name, command in pairs(mappings) do
7676
-- this specific mapping is disabled
77-
if not options[name] then
78-
return
79-
end
77+
if options[name] then
78+
assert(type(options[name]) == "string", string.format("`%s` must be a string", name))
8079

81-
assert(type(options[name]) == "string", string.format("`%s` must be a string", name))
82-
vim.api.nvim_set_keymap("n", options[name], command, { silent = true })
83-
vim.api.nvim_set_keymap("v", options[name], command, { silent = true })
80+
vim.keymap.set({ "n", "v" }, options[name], command)
81+
end
8482
end
8583
end
8684

@@ -93,7 +91,7 @@ function SearchAndReplace.setup(options)
9391
SearchAndReplace.options = SearchAndReplace.defaults(options or {})
9492

9593
register_mappings(SearchAndReplace.options.mappings, {
96-
search_and_replace_by_reference = ":SearchAndReplaceByReference<CR>",
94+
-- search_and_replace_by_reference = ":SearchAndReplaceByReference<CR>",
9795
replace_by_pattern = ":ReplaceByPattern<CR>",
9896
replace_by_reference = ":ReplaceByReference<CR>",
9997
replace_undo = ":ReplaceUndo<CR>",

lua/search-and-replace/state.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ function state:create_buffer(scope, cb)
147147
_G.SearchAndReplace.config.default_replace_prompt_to_selection
148148
and self.selection ~= ""
149149
then
150-
vim.api.nvim_buf_set_text(self.buffer, 0, 0, 0, 0, { self.selection })
150+
vim.fn.prompt_setprompt(self.buffer, self.selection)
151+
-- vim.api.nvim_buf_set_text(self.buffer, 0, 0, 0, 0, { self.selection })
151152
end
152153
end,
153154
group = self.augroup_name,

0 commit comments

Comments
 (0)