Skip to content

Commit 085f856

Browse files
committed
bugfix
1 parent fdebf3b commit 085f856

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

autoload/easycomplete/pum.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,10 @@ function! easycomplete#pum#CursoredItem()
435435
return s:curr_items[s:selected_i - 1]
436436
endfunction
437437

438+
function! easycomplete#pum#select(index)
439+
call s:select(a:index)
440+
endfunction
441+
438442
function! s:select(line_index)
439443
if !s:pumvisible() | return | endif
440444
if a:line_index > len(s:curr_items)

lua/easycomplete/cmdline.lua

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,20 @@ function this.pum_redraw()
3030
if vim.g.easycomplete_cmdline_pattern == '/' then
3131
redraw_queued = true
3232
local ch = vim.fn.nr2char(0x200F)
33-
-- " <bs>"
34-
-- "<c-]>"
35-
-- <c-t>
33+
-- cmdline 模式下模拟 redraw,即要避免整个界面重绘,也要能正确的绘出pumwindow
34+
-- 还要不干扰 cmdline 原本输入的内容,nvim__redraw 和 redraw 都不行,这里用
35+
-- feedkey 一个字符来模拟,目前还不完美,这会导致在大文件时光标有一次闪烁
36+
-- 功能是没问题的,nvim-cmp 用 " <bs>",我感觉"<c-]>"更好一些
37+
-- " <bs>" "<c-]>" <c-t> "<c-a><c-h>" "<c-r><c-r><c-r>" "<c-r><c-r><end>"
38+
-- "<c-g>":匹配下一个
3639
local termcode = vim.api.nvim_replace_termcodes("<c-]>", true, true, true)
3740
vim.schedule(function()
38-
if vim.o.incsearch then
39-
vim.api.nvim_feedkeys(termcode, 'ni', true)
40-
end
41+
-- vim.fn.win_execute(this.pum_winid(), "update")
42+
vim.api.nvim_win_call(this.pum_winid(), function()
43+
if vim.o.incsearch then
44+
vim.api.nvim_feedkeys(termcode, 'ni', true)
45+
end
46+
end)
4147
redraw_queued = false
4248
end)
4349
else
@@ -70,6 +76,11 @@ function this.get_typing_word()
7076
return vim.fn['easycomplete#util#GetTypingWord']()
7177
end
7278

79+
function this.menu_filter(menu_list, word, max_word)
80+
local ret = vim.fn['easycomplete#util#CompleteMenuFilter'](menu_list, word, max_word)
81+
return ret
82+
end
83+
7384
function this.get_buf_keywords(typing_word)
7485
local items_list = vim.fn['easycomplete#sources#buf#GetBufKeywords'](typing_word)
7586
local distinct_items = util.distinct(items_list)
@@ -111,6 +122,10 @@ function this.pum_selected_item()
111122
return vim.fn['easycomplete#pum#CursoredItem']()
112123
end
113124

125+
function this.select(index)
126+
return vim.fn['easycomplete#pum#select'](index)
127+
end
128+
114129
function this.select_next()
115130
vim.fn['easycomplete#pum#next']()
116131
if vim.g.easycomplete_cmdline_pattern == '/' then
@@ -237,7 +252,7 @@ function this.normalize_list(arr, word)
237252
})
238253
end
239254
end
240-
local filtered_items = vim.fn['easycomplete#util#CompleteMenuFilter'](ret, word, 500)
255+
local filtered_items = this.menu_filter(ret, word, 500)
241256
return filtered_items
242257
end
243258

0 commit comments

Comments
 (0)