]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Add failing test for hydrating quickfix list
authorAndreas Louv <andreas@louv.dk>
Sat, 1 Apr 2023 19:24:57 +0000 (21:24 +0200)
committerAndreas Louv <andreas@louv.dk>
Sat, 1 Apr 2023 20:13:10 +0000 (22:13 +0200)
test/clangd_tests.vim
test/tsserver_tests.vim

index 1ce4cd612f26f8a79ef15b89f2cc57f5e0d54d11..07fd96026c4d443dd8d4916f45a336c51b22040f 100644 (file)
@@ -163,19 +163,40 @@ def g:Test_LspShowReferences()
   :LspShowReferences
   sleep 100m
   assert_equal('quickfix', getwinvar(winnr('$'), '&buftype'))
-  var qfl: list<dict<any>> = getloclist(0)
-  assert_equal(bnr, qfl[0].bufnr)
+  var loclist: list<dict<any>> = getloclist(0)
+  assert_equal(bnr, loclist[0].bufnr)
+  assert_equal(3, loclist->len())
+  assert_equal([4, 6], [loclist[0].lnum, loclist[0].col])
+  assert_equal([5, 2], [loclist[1].lnum, loclist[1].col])
+  assert_equal([6, 6], [loclist[2].lnum, loclist[2].col])
+  :only
+  cursor(1, 5)
+  :LspShowReferences
+  assert_equal(1, getloclist(0)->len())
+  loclist = getloclist(0)
+  assert_equal([1, 5], [loclist[0].lnum, loclist[0].col])
+  :lclose
+
+  # Test for opening in qf list
+  g:LspOptionsSet({ useQuickfixForLocations: true })
+  cursor(5, 2)
+  :LspShowReferences
+  sleep 100m
+  assert_equal('quickfix', getwinvar(winnr('$'), '&buftype'))
+  var qfl: list<dict<any>> = getqflist()
   assert_equal(3, qfl->len())
+  assert_equal(bufnr(), qfl[0].bufnr)
   assert_equal([4, 6], [qfl[0].lnum, qfl[0].col])
   assert_equal([5, 2], [qfl[1].lnum, qfl[1].col])
   assert_equal([6, 6], [qfl[2].lnum, qfl[2].col])
   :only
   cursor(1, 5)
   :LspShowReferences
-  assert_equal(1, getloclist(0)->len())
-  qfl = getloclist(0)
+  assert_equal(1, getqflist()->len())
+  qfl = getqflist()
   assert_equal([1, 5], [qfl[0].lnum, qfl[0].col])
-  :lclose
+  :cclose
+  g:LspOptionsSet({ useQuickfixForLocations: false })
 
   # Test for LspPeekReferences
 
index 4130e9352d071cea02df4aadd8e1f019eb717d25..c286d86790dc227461ae7d9e8b61c1031ba34fed 100644 (file)
@@ -49,14 +49,28 @@ def g:Test_LspGoto()
   cursor(7, 8)
   assert_equal('', execute('LspGotoDefinition'))
   sleep 200m
-  var qfl: list<dict<any>> = getloclist(0)
+  var loclist: list<dict<any>> = getloclist(0)
+  assert_equal('quickfix', getwinvar(winnr('$'), '&buftype'))
+  assert_equal(3, loclist->len())
+  assert_equal(bufnr(), loclist[0].bufnr)
+  assert_equal([1, 10, ''], [loclist[0].lnum, loclist[0].col, loclist[0].type])
+  assert_equal([2, 10, ''], [loclist[1].lnum, loclist[1].col, loclist[1].type])
+  assert_equal([3, 10, ''], [loclist[2].lnum, loclist[2].col, loclist[2].type])
+  lclose
+
+  g:LspOptionsSet({ useQuickfixForLocations: true })
+  cursor(7, 8)
+  assert_equal('', execute('LspGotoDefinition'))
+  sleep 200m
+  var qfl: list<dict<any>> = getqflist()
   assert_equal('quickfix', getwinvar(winnr('$'), '&buftype'))
-  assert_equal(bufnr(), qfl[0].bufnr)
   assert_equal(3, qfl->len())
+  assert_equal(bufnr(), qfl[0].bufnr)
   assert_equal([1, 10, ''], [qfl[0].lnum, qfl[0].col, qfl[0].type])
   assert_equal([2, 10, ''], [qfl[1].lnum, qfl[1].col, qfl[1].type])
   assert_equal([3, 10, ''], [qfl[2].lnum, qfl[2].col, qfl[2].type])
-  lclose
+  cclose
+  g:LspOptionsSet({ useQuickfixForLocations: false })
 
   # Opening the preview window with an unsaved buffer displays the "E37: No
   # write since last change" error message.  To disable this message, mark the