mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
fix(lsp): avoid foldclose()
after current window-buffer changed #33901
Problem: Because the buffer in the window may change before the request is completed, foldclose() might be executed on the wrong buffer. Solution: Avoid that.
This commit is contained in:
@@ -345,7 +345,10 @@ function M.foldclose(kind, winid)
|
|||||||
local params = { textDocument = util.make_text_document_params(bufnr) }
|
local params = { textDocument = util.make_text_document_params(bufnr) }
|
||||||
vim.lsp.buf_request_all(bufnr, ms.textDocument_foldingRange, params, function(...)
|
vim.lsp.buf_request_all(bufnr, ms.textDocument_foldingRange, params, function(...)
|
||||||
multi_handler(...)
|
multi_handler(...)
|
||||||
foldclose(kind, winid)
|
-- Ensure this buffer stays as the current buffer after the async request
|
||||||
|
if api.nvim_win_get_buf(winid) == bufnr then
|
||||||
|
foldclose(kind, winid)
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user