From e52bc21844613b75d52f9a22f2b1ea00a54f2fa3 Mon Sep 17 00:00:00 2001 From: newtonne <14221622+newtonne@users.noreply.github.com> Date: Sun, 14 May 2023 15:59:35 +0100 Subject: [PATCH] add tests --- autoload/lsp/diag.vim | 3 +-- test/clangd_tests.vim | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/autoload/lsp/diag.vim b/autoload/lsp/diag.vim index a0dede4..8f8e08d 100644 --- a/autoload/lsp/diag.vim +++ b/autoload/lsp/diag.vim @@ -410,13 +410,12 @@ enddef # Display the diagnostic messages from the LSP server for the current buffer # in a location list export def ShowAllDiags(): void - var save_winid = win_getid() - if !DiagsUpdateLocList(bufnr()) util.WarnMsg($'No diagnostic messages found for {@%}') return endif + var save_winid = win_getid() :lopen if !opt.lspOptions.keepFocusInDiags save_winid->win_gotoid() diff --git a/test/clangd_tests.vim b/test/clangd_tests.vim index fe7c947..5b73987 100644 --- a/test/clangd_tests.vim +++ b/test/clangd_tests.vim @@ -202,6 +202,13 @@ def g:Test_LspShowReferences() :cclose g:LspOptionsSet({ useQuickfixForLocations: false }) + # Test for moving buffer focus to loclist + g:LspOptionsSet({ keepFocusInReferences: true }) + :LspShowReferences + assert_equal('quickfix', getwinvar(0, '&buftype')) + :lclose + g:LspOptionsSet({ keepFocusInReferences: false }) + # Test for LspPeekReferences # Opening the preview window with an unsaved buffer displays the "E37: No @@ -287,6 +294,13 @@ def g:Test_LspDiag() output = execute('LspDiagPrev')->split("\n") assert_equal('Warn: No more diagnostics found', output[0]) + # Test for maintaining buffer focus + g:LspOptionsSet({ keepFocusInDiags: false }) + :LspDiagShow + assert_equal('', getwinvar(0, '&buftype')) + :lclose + g:LspOptionsSet({ keepFocusInDiags: true }) + # :[count]LspDiagNext cursor(3, 1) :2LspDiagNext -- 2.50.0