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

@@ -550,7 +550,7 @@ local function on_complete_done()
return
end
local offset_encoding = client.offset_encoding or 'utf-16'
local position_encoding = client.offset_encoding or 'utf-16'
local resolve_provider = (client.server_capabilities.completionProvider or {}).resolveProvider
local function clear_word()
@@ -576,7 +576,7 @@ local function on_complete_done()
if completion_item.additionalTextEdits and next(completion_item.additionalTextEdits) then
clear_word()
lsp.util.apply_text_edits(completion_item.additionalTextEdits, bufnr, offset_encoding)
lsp.util.apply_text_edits(completion_item.additionalTextEdits, bufnr, position_encoding)
apply_snippet_and_command()
elseif resolve_provider and type(completion_item) == 'table' then
local changedtick = vim.b[bufnr].changedtick
@@ -591,7 +591,7 @@ local function on_complete_done()
if err then
vim.notify_once(err.message, vim.log.levels.WARN)
elseif result and result.additionalTextEdits then
lsp.util.apply_text_edits(result.additionalTextEdits, bufnr, offset_encoding)
lsp.util.apply_text_edits(result.additionalTextEdits, bufnr, position_encoding)
if result.command then
completion_item.command = result.command
end