mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
fix(lsp.buf): use correct offset_encoding for all requests
Problem: `lsp.buf_request` send the same params to all servers and many calls to this pass PositionalParams which depends on the clients offset_encoding. This can result with incorrect params being sent to a server. Solution: `lsp.buf_request` `params` argument can now be passed as a function which takes the client as the first argument. This is used in lsp/buf.lua to construct correct params for each client request.
This commit is contained in:
@ -854,7 +854,7 @@ api.nvim_create_autocmd('VimLeavePre', {
|
||||
---
|
||||
---@param bufnr (integer) Buffer handle, or 0 for current.
|
||||
---@param method (string) LSP method name
|
||||
---@param params table|nil Parameters to send to the server
|
||||
---@param params? table|(fun(client: vim.lsp.Client, bufnr: integer): table?) Parameters to send to the server
|
||||
---@param handler? lsp.Handler See |lsp-handler|
|
||||
--- If nil, follows resolution strategy defined in |lsp-handler-configuration|
|
||||
---@param on_unsupported? fun()
|
||||
@ -879,7 +879,8 @@ function lsp.buf_request(bufnr, method, params, handler, on_unsupported)
|
||||
if client.supports_method(method, { bufnr = bufnr }) then
|
||||
method_supported = true
|
||||
|
||||
local request_success, request_id = client.request(method, params, handler, bufnr)
|
||||
local cparams = type(params) == 'function' and params(client, bufnr) or params --[[@as table?]]
|
||||
local request_success, request_id = client.request(method, cparams, handler, bufnr)
|
||||
-- This could only fail if the client shut down in the time since we looked
|
||||
-- it up and we did the request, which should be rare.
|
||||
if request_success then
|
||||
|
Reference in New Issue
Block a user