neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 7bd4dfd209e9877c9878ce63e59a84492f00251b
parent 4745270bf124a960ccdffdddbb6c27b7bf36ba82
Author: Riley Bruins <ribru17@hotmail.com>
Date:   Thu, 10 Jul 2025 11:12:18 -0700

refactor(lsp): simplify multiline semantic token logic #34698

This commit makes it so that only one call to `vim.str_byteindex` is
needed, at the end of the `end_line`, `end_col` calculations.
Diffstat:
Mruntime/lua/vim/lsp/semantic_tokens.lua | 12+++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/runtime/lua/vim/lsp/semantic_tokens.lua b/runtime/lua/vim/lsp/semantic_tokens.lua @@ -152,17 +152,19 @@ local function tokens_to_ranges(data, bufnr, client, request) local buf_line = lines[line + 1] or '' local end_line = line ---@type integer local start_col = vim.str_byteindex(buf_line, encoding, start_char, false) - local end_col = vim.str_byteindex(buf_line, encoding, end_char, false) - end_char = end_char - vim.str_utfindex(buf_line, encoding) - eol_offset + ---@type integer LuaLS bug, type must be marked explicitly here + local new_end_char = end_char - vim.str_utfindex(buf_line, encoding) - eol_offset -- While end_char goes past the given line, extend the token range to the next line - while end_char > 0 do + while new_end_char > 0 do + end_char = new_end_char end_line = end_line + 1 buf_line = lines[end_line + 1] or '' - end_col = vim.str_byteindex(buf_line, encoding, end_char, false) - end_char = end_char - vim.str_utfindex(buf_line, encoding) - eol_offset + new_end_char = new_end_char - vim.str_utfindex(buf_line, encoding) - eol_offset end + local end_col = vim.str_byteindex(buf_line, encoding, end_char, false) + ranges[#ranges + 1] = { line = line, end_line = end_line,