mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(lsp): forward offset_encoding to apply_text_edits (#17075)
This commit is contained in:
parent
4570df0b43
commit
9304ee3874
@ -184,7 +184,7 @@ function M.formatting_sync(options, timeout_ms)
|
|||||||
|
|
||||||
local result, err = client.request_sync('textDocument/formatting', params, timeout_ms, bufnr)
|
local result, err = client.request_sync('textDocument/formatting', params, timeout_ms, bufnr)
|
||||||
if result and result.result then
|
if result and result.result then
|
||||||
util.apply_text_edits(result.result, bufnr)
|
util.apply_text_edits(result.result, bufnr, client.offset_encoding)
|
||||||
elseif err then
|
elseif err then
|
||||||
vim.notify('vim.lsp.buf.formatting_sync: ' .. err, vim.log.levels.WARN)
|
vim.notify('vim.lsp.buf.formatting_sync: ' .. err, vim.log.levels.WARN)
|
||||||
end
|
end
|
||||||
@ -228,7 +228,7 @@ function M.formatting_seq_sync(options, timeout_ms, order)
|
|||||||
local params = util.make_formatting_params(options)
|
local params = util.make_formatting_params(options)
|
||||||
local result, err = client.request_sync("textDocument/formatting", params, timeout_ms, vim.api.nvim_get_current_buf())
|
local result, err = client.request_sync("textDocument/formatting", params, timeout_ms, vim.api.nvim_get_current_buf())
|
||||||
if result and result.result then
|
if result and result.result then
|
||||||
util.apply_text_edits(result.result, bufnr)
|
util.apply_text_edits(result.result, bufnr, client.offset_encoding)
|
||||||
elseif err then
|
elseif err then
|
||||||
vim.notify(string.format("vim.lsp.buf.formatting_seq_sync: (%s) %s", client.name, err), vim.log.levels.WARN)
|
vim.notify(string.format("vim.lsp.buf.formatting_seq_sync: (%s) %s", client.name, err), vim.log.levels.WARN)
|
||||||
end
|
end
|
||||||
|
@ -233,13 +233,15 @@ end
|
|||||||
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_rangeFormatting
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_rangeFormatting
|
||||||
M['textDocument/rangeFormatting'] = function(_, result, ctx, _)
|
M['textDocument/rangeFormatting'] = function(_, result, ctx, _)
|
||||||
if not result then return end
|
if not result then return end
|
||||||
util.apply_text_edits(result, ctx.bufnr)
|
local client = vim.lsp.get_client_by_id(ctx.client_id)
|
||||||
|
util.apply_text_edits(result, ctx.bufnr, client.offset_encoding)
|
||||||
end
|
end
|
||||||
|
|
||||||
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_formatting
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_formatting
|
||||||
M['textDocument/formatting'] = function(_, result, ctx, _)
|
M['textDocument/formatting'] = function(_, result, ctx, _)
|
||||||
if not result then return end
|
if not result then return end
|
||||||
util.apply_text_edits(result, ctx.bufnr)
|
local client = vim.lsp.get_client_by_id(ctx.client_id)
|
||||||
|
util.apply_text_edits(result, ctx.bufnr, client.offset_encoding)
|
||||||
end
|
end
|
||||||
|
|
||||||
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_completion
|
--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_completion
|
||||||
|
@ -771,7 +771,7 @@ function M.apply_workspace_edit(workspace_edit, offset_encoding)
|
|||||||
|
|
||||||
for uri, changes in pairs(all_changes) do
|
for uri, changes in pairs(all_changes) do
|
||||||
local bufnr = vim.uri_to_bufnr(uri)
|
local bufnr = vim.uri_to_bufnr(uri)
|
||||||
M.apply_text_edits(changes, bufnr)
|
M.apply_text_edits(changes, bufnr, offset_encoding)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user