]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Add test for inline diagnostic highlight
authorAndreas Louv <andreas@louv.dk>
Thu, 30 Mar 2023 17:38:25 +0000 (19:38 +0200)
committerAndreas Louv <andreas@louv.dk>
Thu, 30 Mar 2023 23:19:51 +0000 (01:19 +0200)
test/clangd_tests.vim

index 14bbc14ad3fef499522adeb2469d4cd71859090f..695d7128d5875d3284addc4ec10c143a81ca7977 100644 (file)
@@ -3,7 +3,7 @@ vim9script
 
 source common.vim
 
-var lspOpts = {autoComplete: false}
+var lspOpts = {autoComplete: false, highlightDiagInline: true}
 g:LspOptionsSet(lspOpts)
 
 var lspServers = [{
@@ -271,6 +271,44 @@ def g:Test_LspDiag()
   :%bw!
 enddef
 
+# Test for highlight diag inline
+def g:Test_LspHighlightDiagInline()
+  :silent! edit Xtest.c
+  sleep 200m
+  setline(1, [
+    'int main()',
+    '{',
+      '    struct obj obj',
+      '',
+      '    return 1;',
+    '}',
+  ])
+
+  # TODO: Waiting count doesn't include Warning, Info, and Hint diags
+  g:WaitForDiags(2)
+
+  var props = prop_list(1)
+  assert_equal(0, props->len())
+  props = prop_list(2)
+  assert_equal(0, props->len())
+  props = prop_list(3)
+  assert_equal(2, props->len())
+  assert_equal([
+    {'id': 0, 'col': 12, 'type_bufnr': 0, 'end': 1, 'type': 'LspDiagInlineInfo', 'length': 3, 'start': 1},
+    {'id': 0, 'col': 16, 'type_bufnr': 0, 'end': 1, 'type': 'LspDiagInlineError', 'length': 3, 'start': 1}
+  ], props)
+  props = prop_list(4)
+  assert_equal(0, props->len())
+  props = prop_list(5)
+  assert_equal(1, props->len())
+  assert_equal([{'id': 0, 'col': 5, 'type_bufnr': 0, 'end': 1, 'type': 'LspDiagInlineError', 'length': 6, 'start': 1}], props)
+  props = prop_list(6)
+  assert_equal(0, props->len())
+
+  bw!
+
+enddef
+
 # Test for :LspCodeAction
 def g:Test_LspCodeAction()
   silent! edit Xtest.c