]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Add test to confirm the correct diagnostic is found for "LspDiagCurrent"
authorAndreas Louv <andreas@louv.dk>
Mon, 20 Mar 2023 14:00:58 +0000 (15:00 +0100)
committerAndreas Louv <andreas@louv.dk>
Mon, 20 Mar 2023 14:00:58 +0000 (15:00 +0100)
test/tsserver_tests.vim

index b5ea71045d8c1cdfc583da358846f3cbe3bd85be..ad08489d3b32212f0c5d6ebd6f366f2bb40df94e 100644 (file)
@@ -18,11 +18,11 @@ def g:Test_LspDiag()
 
   # This tests that two diagnostics can be on the same line
   var lines: list<string> = [
-    'export obj = {',
-    '  foo: 1,',
-    '  bar: 2,',
-    '  baz: 3',
-    '}'
+    '  export obj = {',
+    '    foo: 1,',
+    '    bar: 2,',
+    '    baz: 3',
+    '  }'
   ]
 
   setline(1, lines)
@@ -34,26 +34,39 @@ def g:Test_LspDiag()
   assert_equal('quickfix', getwinvar(winnr('$'), '&buftype'))
   assert_equal(bnr, qfl[0].bufnr)
   assert_equal(2, qfl->len())
-  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])
+  assert_equal([1, 3, 'E'], [qfl[0].lnum, qfl[0].col, qfl[0].type])
+  assert_equal([1, 10, '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([1, 10], [line('.'), col('.')])
 
   assert_equal('', execute('LspDiagPrev'))
-  assert_equal([1, 1], [line('.'), col('.')])
+  assert_equal([1, 3], [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([1, 3], [line('.'), col('.')])
   assert_equal('', execute('LspDiagNext'))
-  assert_equal([1, 8], [line('.'), col('.')])
+  assert_equal([1, 10], [line('.'), col('.')])
+
+  g:LspOptionsSet({showDiagInPopup: false})
+  for i in range(1, 3)
+    cursor(1, i)
+    output = execute('LspDiagCurrent')->split('\n')
+    assert_equal('Declaration or statement expected.', output[0])
+  endfor
+  for i in range(4, 16)
+    cursor(1, i)
+    output = execute('LspDiagCurrent')->split('\n')
+    assert_equal('Cannot find name ''obj''.', output[0])
+  endfor
+  g:LspOptionsSet({showDiagInPopup: true})
 
   :%bw!
 enddef