diff options
author | Gregory Anders <greg@gpanders.com> | 2021-09-20 12:32:21 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-20 11:32:21 -0700 |
commit | 0216aed20c9f5960506155e3d722f5ee5e807720 (patch) | |
tree | 22df91ca96b8bc69d72b3021e4baa3ec26f3838b /test/functional/lua/diagnostic_spec.lua | |
parent | f4ca3a29ddcb0c98e8e09c45a6342af709f8cc45 (diff) | |
download | rneovim-0216aed20c9f5960506155e3d722f5ee5e807720.tar.gz rneovim-0216aed20c9f5960506155e3d722f5ee5e807720.tar.bz2 rneovim-0216aed20c9f5960506155e3d722f5ee5e807720.zip |
fix(diagnostic): clamp line numbers in display layer (#15729)
Some parts of LSP need to use cached diagnostics as sent from the LSP
server unmodified. Rather than fixing invalid line numbers when
diagnostics are first set, fix them when they are displayed to the user
(e.g. in show() or one of the get_next/get_prev family of functions).
Diffstat (limited to 'test/functional/lua/diagnostic_spec.lua')
-rw-r--r-- | test/functional/lua/diagnostic_spec.lua | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/functional/lua/diagnostic_spec.lua b/test/functional/lua/diagnostic_spec.lua index 29dd5c60da..e542b02abe 100644 --- a/test/functional/lua/diagnostic_spec.lua +++ b/test/functional/lua/diagnostic_spec.lua @@ -842,6 +842,18 @@ describe('vim.diagnostic', function() return #vim.api.nvim_buf_get_lines(popup_bufnr, 0, -1, false) ]]) end) + + it('clamps diagnostic line numbers within the valid range', function() + eq(1, exec_lua [[ + local diagnostics = { + make_error("Syntax error", 6, 0, 6, 0), + } + vim.api.nvim_win_set_buf(0, diagnostic_bufnr) + vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics) + local popup_bufnr, winnr = vim.diagnostic.show_line_diagnostics({show_header = false}, diagnostic_bufnr, 5) + return #vim.api.nvim_buf_get_lines(popup_bufnr, 0, -1, false) + ]]) + end) end) describe('set_signs()', function() |