diff options
author | Gregory Anders <greg@gpanders.com> | 2021-11-19 11:31:33 -0700 |
---|---|---|
committer | Gregory Anders <greg@gpanders.com> | 2021-11-19 11:37:45 -0700 |
commit | 34bb5fa5a942708c32b0e68eca02261d04e51ca6 (patch) | |
tree | 23d90480e23d49fe35d7f6d55725e84f6851675c /runtime/lua/vim/diagnostic.lua | |
parent | 2abc799ffd8b3b250f0ffce2f74a930ad3d19cf3 (diff) | |
download | rneovim-34bb5fa5a942708c32b0e68eca02261d04e51ca6.tar.gz rneovim-34bb5fa5a942708c32b0e68eca02261d04e51ca6.tar.bz2 rneovim-34bb5fa5a942708c32b0e68eca02261d04e51ca6.zip |
fix(diagnostic): fix navigation with diagnostics placed past end of line
Diffstat (limited to 'runtime/lua/vim/diagnostic.lua')
-rw-r--r-- | runtime/lua/vim/diagnostic.lua | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index 0ffc263ec1..2a26a36d10 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -467,13 +467,14 @@ local function next_diagnostic(position, search_forward, bufnr, opts, namespace) lnum = (lnum + line_count) % line_count end if line_diagnostics[lnum] and not vim.tbl_isempty(line_diagnostics[lnum]) then + local line_length = #vim.api.nvim_buf_get_lines(bufnr, lnum, lnum + 1, true)[1] local sort_diagnostics, is_next if search_forward then sort_diagnostics = function(a, b) return a.col < b.col end - is_next = function(diagnostic) return diagnostic.col > position[2] end + is_next = function(d) return math.min(d.col, line_length - 1) > position[2] end else sort_diagnostics = function(a, b) return a.col > b.col end - is_next = function(diagnostic) return diagnostic.col < position[2] end + is_next = function(d) return math.min(d.col, line_length - 1) < position[2] end end table.sort(line_diagnostics[lnum], sort_diagnostics) if i == 0 then |