]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Add simple test to confirm multiple diagnostics can be on one line
authorAndreas Louv <andreas@louv.dk>
Mon, 20 Mar 2023 12:47:42 +0000 (13:47 +0100)
committerAndreas Louv <andreas@louv.dk>
Mon, 20 Mar 2023 13:55:20 +0000 (14:55 +0100)
test/tsserver_tests.vim

index 6b5f359680f8adf4a24f3e21f87b6d21f23c281e..b5ea71045d8c1cdfc583da358846f3cbe3bd85be 100644 (file)
@@ -13,25 +13,48 @@ echomsg systemlist($'{lspServers[0].path} --version')
 def g:Test_LspDiag()
   :silent! edit Xtest.ts
   sleep 200m
+
+  var bnr: number = bufnr()
+
+  # This tests that two diagnostics can be on the same line
   var lines: list<string> = [
-    '  let person: string = "rob";',
-    '  person = 10;',
-    '  MyFunc();'
+    'export obj = {',
+    '  foo: 1,',
+    '  bar: 2,',
+    '  baz: 3',
+    '}'
   ]
+
   setline(1, lines)
   :sleep 1
   g:WaitForDiags(2)
-  var bnr: number = bufnr()
   :redraw!
   :LspDiagShow
   var qfl: list<dict<any>> = getloclist(0)
   assert_equal('quickfix', getwinvar(winnr('$'), '&buftype'))
   assert_equal(bnr, qfl[0].bufnr)
   assert_equal(2, qfl->len())
-  assert_equal([2, 3, 'E'], [qfl[0].lnum, qfl[0].col, qfl[0].type])
-  assert_equal([3, 3, 'E'], [qfl[1].lnum, qfl[1].col, qfl[1].type])
+  assert_equal([1, 1, 'E'], [qfl[0].lnum, qfl[0].col, qfl[0].type])
+  assert_equal([1, 8, 'E'], [qfl[1].lnum, qfl[1].col, qfl[1].type])
   close
 
+  :sleep 100m
+  cursor(5, 1)
+  assert_equal('', execute('LspDiagPrev'))
+  assert_equal([1, 8], [line('.'), col('.')])
+
+  assert_equal('', execute('LspDiagPrev'))
+  assert_equal([1, 1], [line('.'), col('.')])
+
+  var output = execute('LspDiagPrev')->split("\n")
+  assert_equal('Error: No more diagnostics found', output[0])
+
+  cursor(5, 1)
+  assert_equal('', execute('LspDiagFirst'))
+  assert_equal([1, 1], [line('.'), col('.')])
+  assert_equal('', execute('LspDiagNext'))
+  assert_equal([1, 8], [line('.'), col('.')])
+
   :%bw!
 enddef