refactor(lsp): rename offset_encoding to position_encoding #31286

Problem:
LSP spec uses the term "position encoding" where we say "offset encoding".

Solution:
- Rename it everywhere except `vim.lsp.Client.offset_encoding` (which would be breaking).
- Mention "position encoding" in the documentation for `vim.lsp.Client.offset_encoding`.
This commit is contained in:
Yi Ming
2024-11-26 00:06:05 +08:00
committed by GitHub
parent a811d4babd
commit 165b099fa3
12 changed files with 188 additions and 175 deletions

View File

@@ -638,14 +638,14 @@ function M.rename(new_name, opts)
local cword = vim.fn.expand('<cword>')
--- @param range lsp.Range
--- @param offset_encoding string
local function get_text_at_range(range, offset_encoding)
--- @param position_encoding string
local function get_text_at_range(range, position_encoding)
return api.nvim_buf_get_text(
bufnr,
range.start.line,
util._get_line_byte_from_position(bufnr, range.start, offset_encoding),
util._get_line_byte_from_position(bufnr, range.start, position_encoding),
range['end'].line,
util._get_line_byte_from_position(bufnr, range['end'], offset_encoding),
util._get_line_byte_from_position(bufnr, range['end'], position_encoding),
{}
)[1]
end