@@ -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' ]()
7177end
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+
7384function 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' ]()
112123end
113124
125+ function this .select (index )
126+ return vim .fn [' easycomplete#pum#select' ](index )
127+ end
128+
114129function 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
242257end
243258
0 commit comments