File tree Expand file tree Collapse file tree 2 files changed +31
-8
lines changed
Expand file tree Collapse file tree 2 files changed +31
-8
lines changed Original file line number Diff line number Diff line change @@ -241,8 +241,10 @@ function! easycomplete#pum#WinScrolled()
241241 call easycomplete#ShowCompleteInfoByItem (curr_item)
242242 endif
243243 endif
244+ " 当从 cmdline 触发时没有调用 WinScrolled,是因为cmdline激活状态时主屏渲染停滞
245+ " 所以要注意在 select() 函数中手动触发一下RenderScrollThumb
244246 if has_key (v: event , s: pum_window )
245- " pum 窗口的移动
247+ " pum 窗口的移动和滚动都会调用这里
246248 call s: RenderScrollThumb ()
247249 endif
248250endfunction
@@ -441,6 +443,18 @@ function! s:select(line_index)
441443 endif
442444 call s: HLCursordFuzzyChar (" CustomFuzzyMatch" , prefix_length)
443445 endif
446+ " cmdline 中弹出 pum 时,主线程的非必要渲染会停止,所以往往需要手动加 redraw 才能触发渲染
447+ " 因此在 cmdline 中弹出 pum 时机做了一个延迟,导致渲染延后,以至于获得的 PumPosition 不是
448+ " 最初计算的值,导致 scrollbar 的位置计算错误,重新渲染后一般又会正确,都是渲染停滞导致的
449+ " 因此这里加上一个强制的延迟,强制重新渲染 scroll 来解决
450+ if exists (" g:easycomplete_cmdline_typing" ) && g: easycomplete_cmdline_typing == 1
451+ call timer_start (10 , { - > s: RenderScroll () })
452+ endif
453+ endfunction
454+
455+ function s: RenderScroll ()
456+ call s: RenderScrollBar ()
457+ call s: RenderScrollThumb ()
444458endfunction
445459
446460function ! s: CharCounts (str, char)
Original file line number Diff line number Diff line change @@ -55,24 +55,33 @@ function flush()
5555 pum_close ()
5656end
5757
58+ function pum_selected ()
59+ return vim .fn [' easycomplete#pum#CompleteCursored' ]()
60+ end
61+
62+ function pum_selected_item ()
63+ return vim .fn [' easycomplete#pum#CursoredItem' ]()
64+ end
65+
5866function M .select_next ()
5967 vim .fn [' easycomplete#pum#next' ]()
60- local word = vim .fn [' easycomplete#pum#CursoredItem' ]()
6168 zizz ()
62- do return " x" end
63-
6469 local backing_count = vim .fn .getcmdpos () - cmdline_start_cmdpos
6570 local oprator_str = string.rep (" \b " , backing_count )
66- local new_whole_word = oprator_str .. word
71+ local new_whole_word = " "
72+ if pum_selected () then
73+ local item = pum_selected_item ()
74+ local word = item .word
75+ new_whole_word = oprator_str .. word
76+ else
77+ new_whole_word = oprator_str
78+ end
6779 return new_whole_word
6880end
6981
7082function M .select_prev ()
7183 vim .fn [' easycomplete#pum#prev' ]()
7284 zizz ()
73- local word = vim .fn [' easycomplete#pum#CursoredItem' ]()
74-
75-
7685end
7786
7887local function bind_cmdline_event ()
You can’t perform that action at this time.
0 commit comments