]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
add tests
authornewtonne <14221622+newtonne@users.noreply.github.com>
Sun, 14 May 2023 14:59:35 +0000 (15:59 +0100)
committernewtonne <14221622+newtonne@users.noreply.github.com>
Sun, 14 May 2023 14:59:35 +0000 (15:59 +0100)
autoload/lsp/diag.vim
test/clangd_tests.vim

index a0dede44ec965a3f1ee197ad4e044d139d77ecae..8f8e08d15ac73280f22edf7bab76e5efc3777c8e 100644 (file)
@@ -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()
index fe7c9474dbb4dcf57efb4342abf850c840b9906a..5b7398788f0ce3bba66bd78eabc04dd1d51d90fc 100644 (file)
@@ -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