diff options
author | Andre Toerien <49614525+AThePeanut4@users.noreply.github.com> | 2024-06-04 23:35:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-04 16:35:44 -0500 |
commit | f69937fdbd162630c35e119e67bbbf052558c0e0 (patch) | |
tree | 7a61a1a9fe77f73e094c661afe8576bce6ad60ab /runtime/lua/vim | |
parent | 946a839aa9621e11f53e7044e594132d0497b99f (diff) | |
download | rneovim-f69937fdbd162630c35e119e67bbbf052558c0e0.tar.gz rneovim-f69937fdbd162630c35e119e67bbbf052558c0e0.tar.bz2 rneovim-f69937fdbd162630c35e119e67bbbf052558c0e0.zip |
fix(diagnostic): fix float scope filtering (#29134)
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r-- | runtime/lua/vim/diagnostic.lua | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index c6649ae09b..9342727b2e 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -1857,16 +1857,19 @@ function M.open_float(opts, ...) if scope == 'line' then --- @param d vim.Diagnostic diagnostics = vim.tbl_filter(function(d) - return lnum >= d.lnum and lnum <= d.end_lnum + return lnum >= d.lnum + and lnum <= d.end_lnum + and (d.lnum == d.end_lnum or lnum ~= d.end_lnum or d.end_col ~= 0) end, diagnostics) elseif scope == 'cursor' then - -- LSP servers can send diagnostics with `end_col` past the length of the line + -- If `col` is past the end of the line, show if the cursor is on the last char in the line local line_length = #api.nvim_buf_get_lines(bufnr, lnum, lnum + 1, true)[1] --- @param d vim.Diagnostic diagnostics = vim.tbl_filter(function(d) - return d.lnum == lnum - and math.min(d.col, line_length - 1) <= col - and (d.end_col >= col or d.end_lnum > lnum) + return lnum >= d.lnum + and lnum <= d.end_lnum + and (lnum ~= d.lnum or col >= math.min(d.col, line_length - 1)) + and ((d.lnum == d.end_lnum and d.col == d.end_col) or lnum ~= d.end_lnum or col < d.end_col) end, diagnostics) end |