Skip to content

Commit 5356ffd

Browse files
committed
fix: diagnostics with column index out of range (#51)
1 parent fbdcbf8 commit 5356ffd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lua/null-ls/helpers/diagnostics.lua

+3-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ local make_diagnostic = function(entries, defaults, attr_adapters, params, offse
6868
-- we need to convert the column number to a byte index.
6969
-- See: https://github.com/nvimtools/none-ls.nvim/issues/19#issuecomment-1820127436
7070
if entries["col"] ~= nil and content_line ~= nil then
71-
local byte_index_col = vim.str_byteindex(content_line, tonumber(entries["col"]))
71+
local col = tonumber(entries["col"]) or (1 / 0)
72+
col = math.min(col, string.len(content_line))
73+
local byte_index_col = vim.str_byteindex(content_line, col)
7274
entries["col"] = tostring(byte_index_col)
7375
end
7476

0 commit comments

Comments
 (0)