Skip to content

Commit 4bd884d

Browse files
committed
优化 lint popup 的逻辑,进一步检查 lintcurrentline 是否必要
1 parent b106e2a commit 4bd884d

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

autoload/easycomplete.vim

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,8 @@ endfunction
506506
function! easycomplete#InsertLeave()
507507
if easycomplete#ok('g:easycomplete_diagnostics_enable')
508508
call easycomplete#lint()
509-
call easycomplete#sign#LintCurrentLine()
509+
" call easycomplete#sign#LintCurrentLine()
510+
call easycomplete#sign#LintPopup()
510511
endif
511512
call easycomplete#tabnine#flush()
512513
call s:flush()
@@ -2606,7 +2607,8 @@ function! easycomplete#CursorMoved()
26062607
call timer_stop(s:easycomplete_cursor_move_timer)
26072608
let s:easycomplete_cursor_move_timer = 0
26082609
endif
2609-
let s:easycomplete_cursor_move_timer = timer_start(35, { -> easycomplete#sign#LintCurrentLine() })
2610+
" let s:easycomplete_cursor_move_timer = timer_start(35, { -> easycomplete#sign#LintCurrentLine() })
2611+
let s:easycomplete_cursor_move_timer = timer_start(80, { -> easycomplete#sign#LintPopup() })
26102612
endif
26112613

26122614
" 上下移动时关闭hover,左右移动时不关闭
@@ -2657,7 +2659,7 @@ function! easycomplete#CursorHold()
26572659
call easycomplete#lint()
26582660
if easycomplete#ok('g:easycomplete_diagnostics_enable')
26592661
\ && easycomplete#ok('g:easycomplete_diagnostics_hover')
2660-
call easycomplete#sign#LintPopup()
2662+
" call easycomplete#sign#LintPopup()
26612663
endif
26622664
endfunction
26632665

autoload/easycomplete/popup.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,15 @@ function! s:lint(content, hl, ft)
158158
let s:float_opt = {}
159159
try
160160
if distance < 5
161+
let b:easycomplete_echo_lint_msg = 1
161162
echo a:content[0]
162163
return
163164
endif
164165
let trimed_content = easycomplete#util#lintTrim(a:content[0], distance, 2)
165166
let l:content = [trimed_content["str"]]
166167
if trimed_content["trimed"]
167168
" TODO 关闭
169+
let b:easycomplete_echo_lint_msg = 1
168170
echo a:content[0]
169171
endif
170172
call s:InitBuf(l:content, 'float', a:ft)

autoload/easycomplete/sign.vim

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ function! easycomplete#sign#DiagHoverFlush()
8383
endif
8484
endif
8585
let g:easycomplete_diagnostics_last_ln = 0
86-
echo ""
86+
if exists("b:easycomplete_echo_lint_msg") && b:easycomplete_echo_lint_msg == 1
87+
" 有 lint msg 的残留则清空,否则不应该做动作
88+
echo ""
89+
let b:easycomplete_echo_lint_msg = 0
90+
endif
8791
endfunction
8892

8993
" 只清空当前buf的diagnostics
@@ -495,8 +499,6 @@ function! easycomplete#sign#LintPopup()
495499
if g:easycomplete_diagnostics_last_ln != ctx["lnum"]
496500
call easycomplete#sign#DiagHoverFlush()
497501
endif
498-
499-
500502
" 如果当前行没有 lintinfo, 则清空后直接返回
501503
let diagnostics_info = easycomplete#sign#GetDiagnosticsInfo(ctx["lnum"], ctx["col"])
502504
if empty(diagnostics_info)

0 commit comments

Comments
 (0)