test/tsserver_tests.vim | 35 ++++++++++++++++++++++++----------- diff --git a/test/tsserver_tests.vim b/test/tsserver_tests.vim index b5ea71045d8c1cdfc583da358846f3cbe3bd85be..ad08489d3b32212f0c5d6ebd6f366f2bb40df94e 100644 --- a/test/tsserver_tests.vim +++ b/test/tsserver_tests.vim @@ -18,11 +18,11 @@ var bnr: number = bufnr() # This tests that two diagnostics can be on the same line var lines: list = [ - 'export obj = {', - ' foo: 1,', - ' bar: 2,', - ' baz: 3', - '}' + ' export obj = {', + ' foo: 1,', + ' bar: 2,', + ' baz: 3', + ' }' ] setline(1, lines) @@ -34,26 +34,39 @@ var qfl: list> = getloclist(0) 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