mirror of
https://github.com/neovim/neovim.git
synced 2025-10-15 14:26:07 +00:00
fix(lsp): improper diagnostic end_col computation
**Problem:** For multiline diagnostics, the end column was improperly
calculated by checking the byte index of the character position on the
*start* line.
**Solution:** Calculate the byte index for end_col using the *end* line.
(cherry picked from commit 5d1fd4aca5
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
cf73f21c07
commit
6b69b3217b
@@ -93,12 +93,16 @@ local function diagnostic_lsp_to_vim(diagnostics, bufnr, client_id)
|
||||
message = diagnostic.message.value
|
||||
end
|
||||
local line = buf_lines and buf_lines[start.line + 1] or ''
|
||||
local end_line = line
|
||||
if _end.line > start.line then
|
||||
end_line = buf_lines and buf_lines[_end.line + 1] or ''
|
||||
end
|
||||
--- @type vim.Diagnostic
|
||||
return {
|
||||
lnum = start.line,
|
||||
col = vim.str_byteindex(line, position_encoding, start.character, false),
|
||||
end_lnum = _end.line,
|
||||
end_col = vim.str_byteindex(line, position_encoding, _end.character, false),
|
||||
end_col = vim.str_byteindex(end_line, position_encoding, _end.character, false),
|
||||
severity = severity_lsp_to_vim(diagnostic.severity),
|
||||
message = message,
|
||||
source = diagnostic.source,
|
||||
|
Reference in New Issue
Block a user