Skip to content

Commit 47fd145

Browse files
committed
bugfix for insearch
1 parent 677e053 commit 47fd145

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

lua/easycomplete/cmdline.lua

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function this.pum_redraw()
3333
local termcode = vim.api.nvim_replace_termcodes(" <bs>", true, true, true)
3434
vim.schedule(function()
3535
if vim.o.incsearch then
36-
vim.api.nvim_feedkeys(termcode, 'ni', false)
36+
vim.api.nvim_feedkeys(termcode, 'ni', true)
3737
end
3838
redraw_queued = false
3939
end)
@@ -128,7 +128,7 @@ function this.select_prev()
128128
return new_whole_word
129129
end
130130

131-
-- Tab 切换 pum 选项的动作
131+
-- :cmd 模式下Tab 切换 pum 选项的动作
132132
function this.get_tab_returing_opword()
133133
local backing_count = vim.fn.getcmdpos() - cmdline_start_cmdpos
134134
local oprator_str = string.rep("\b", backing_count)
@@ -143,6 +143,11 @@ function this.get_tab_returing_opword()
143143
return new_whole_word
144144
end
145145

146+
-- / search 模式下回车键返回的内容
147+
function this.get_search_returing_opword()
148+
149+
end
150+
146151
function this.bind_cmdline_event()
147152
local augroup = vim.api.nvim_create_augroup('CustomCmdlineComplete', { clear = true })
148153

@@ -183,7 +188,7 @@ function this.bind_cmdline_event()
183188
end
184189
vim.g.easycomplete_cmdline_typing = 1
185190
-- TODO 匹配模式闪烁问题没解决,先关闭
186-
if vim.g.easycomplete_cmdline_pattern == '/' then
191+
if vim.g.easycomplete_cmdline_pattern == '/' and key_str ~= '\r'then
187192
-- jayli 先关掉,继续调试
188193
do return end
189194
if util.zizzing() then
@@ -274,13 +279,22 @@ end
274279

275280
function this.cr_handler()
276281
if this.pum_visible() and this.pum_selected() then
277-
this.pum_close()
278-
vim.defer_fn(function()
279-
if this.char_before_cursor() == "/" then
280-
this.do_path_complete()
281-
end
282-
end, 30)
283-
return false -- 阻止回车
282+
if vim.g.easycomplete_cmdline_pattern == ":" then
283+
this.pum_close()
284+
vim.defer_fn(function()
285+
if this.char_before_cursor() == "/" then
286+
this.do_path_complete()
287+
end
288+
end, 30)
289+
elseif vim.g.easycomplete_cmdline_pattern == "/" then
290+
local opr = this.get_tab_returing_opword()
291+
this.pum_close()
292+
vim.defer_fn(function()
293+
vim.api.nvim_feedkeys(opr, 'ni', true)
294+
util.zizz()
295+
end, 30)
296+
end
297+
return false -- 组织回车
284298
else
285299
return true -- 执行回车
286300
end

0 commit comments

Comments
 (0)