diff options
author | Gregory Anders <8965202+gpanders@users.noreply.github.com> | 2021-10-19 16:27:49 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-19 16:27:49 -0600 |
commit | a2994c82e355b6591299d16df1dead86e875acd1 (patch) | |
tree | 1ef80a02fb538e185207e5842fdb3d7ba15564f0 /runtime/lua/vim/diagnostic.lua | |
parent | 208d259e83c47a9c6d2ef66f2cb15281aacda563 (diff) | |
download | rneovim-a2994c82e355b6591299d16df1dead86e875acd1.tar.gz rneovim-a2994c82e355b6591299d16df1dead86e875acd1.tar.bz2 rneovim-a2994c82e355b6591299d16df1dead86e875acd1.zip |
fix(diagnostic): handle diagnostics placed past the end of line (#16095)
Diffstat (limited to 'runtime/lua/vim/diagnostic.lua')
-rw-r--r-- | runtime/lua/vim/diagnostic.lua | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index f5ca034abc..53a31f4d3c 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -1146,8 +1146,12 @@ function M.open_float(bufnr, opts) return d.lnum == lnum end, diagnostics) elseif scope == "cursor" then + -- LSP servers can send diagnostics with `end_col` past the length of the line + local line_length = #vim.api.nvim_buf_get_lines(bufnr, lnum, lnum + 1, true)[1] diagnostics = vim.tbl_filter(function(d) - return d.lnum == lnum and d.col <= col and (d.end_col >= col or d.end_lnum > lnum) + return d.lnum == lnum + and math.min(d.col, line_length - 1) <= col + and (d.end_col >= col or d.end_lnum > lnum) end, diagnostics) end |