From 028be3debb6fef94b7042580da71df2fcea287ed Mon Sep 17 00:00:00 2001
From: Andreas Louv <andreas@louv.dk>
Date: Mon, 20 Mar 2023 13:47:42 +0100
Subject: [PATCH] Add simple test to confirm multiple diagnostics can be on one
 line

---
 test/tsserver_tests.vim | 35 +++++++++++++++++++++++++++++------
 1 file changed, 29 insertions(+), 6 deletions(-)

diff --git a/test/tsserver_tests.vim b/test/tsserver_tests.vim
index 6b5f359..b5ea710 100644
--- a/test/tsserver_tests.vim
+++ b/test/tsserver_tests.vim
@@ -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
 
-- 
2.51.0