From 9946229d8337caa549f77016e2b99e737ef2578e Mon Sep 17 00:00:00 2001 From: Illia Bobyr Date: Fri, 19 Jul 2024 18:51:19 -0700 Subject: [PATCH] Diagnostic float: Record position before debounce time It seems that we should be recording the current buffer, cursor position and change tick before we wait to see if the float should be shown or not. Otherwise, if any of the above change during the `g:lsp_diagnostics_float_delay` our recording would be incorrect. --- autoload/lsp/internal/diagnostics/float.vim | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/autoload/lsp/internal/diagnostics/float.vim b/autoload/lsp/internal/diagnostics/float.vim index f7f40a158..82469ca63 100644 --- a/autoload/lsp/internal/diagnostics/float.vim +++ b/autoload/lsp/internal/diagnostics/float.vim @@ -26,9 +26,17 @@ function! lsp#internal#diagnostics#float#_enable() abort \ ), \ lsp#callbag#filter({_->g:lsp_diagnostics_float_cursor}), \ lsp#callbag#tap({_->s:hide_float()}), + \ lsp#callbag#map({_->{ + \ 'bufnr': bufnr('%'), + \ 'curpos': getcurpos()[0:2], + \ 'changedtick': b:changedtick + \ }}), \ lsp#callbag#debounceTime(g:lsp_diagnostics_float_delay), - \ lsp#callbag#map({_->{'bufnr': bufnr('%'), 'curpos': getcurpos()[0:2], 'changedtick': b:changedtick }}), - \ lsp#callbag#distinctUntilChanged({a,b -> a['bufnr'] == b['bufnr'] && a['curpos'] == b['curpos'] && a['changedtick'] == b['changedtick']}), + \ lsp#callbag#distinctUntilChanged({a,b -> + \ a['bufnr'] == b['bufnr'] + \ && a['curpos'] == b['curpos'] + \ && a['changedtick'] == b['changedtick'] + \ }), \ lsp#callbag#filter({_->mode() is# 'n'}), \ lsp#callbag#filter({_->getbufvar(bufnr('%'), '&buftype') !=# 'terminal' }), \ lsp#callbag#map({_->lsp#internal#diagnostics#under_cursor#get_diagnostic()}),