-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(lsp): update the changetracking buffer state on reload #28721
Conversation
d2f40a9
to
3b0a920
Compare
I'm not sure how to test this. |
a1a0b4b
to
648b935
Compare
I'm not attached to this implementation. If someone wants to suggest an alternate implementation or make a spin-off PR I'd be more than happy to test it out. |
133bc15
to
9cb8ede
Compare
@mfussenegger I was looking through the history and it seems like you've done the most work in this area of the code. Any feedback would be appreciated. |
Another way to fix this would be do change the on_reload = function()
local params = { textDocument = { uri = uri } }
local clients = lsp.get_clients({ bufnr = bufnr })
for _, client in ipairs(clients) do
changetracking.reset_buf(client, bufnr)
if vim.tbl_get(client.server_capabilities, 'textDocumentSync', 'openClose') then
client.notify(ms.textDocument_didClose, params)
end
end
for _, client in ipairs(clients) do
client:_text_document_did_open_handler(bufnr)
end
end, |
Problem: The changetracking state can de-sync when reloading a buffer with more than one LSP client attached. Solution: Update the changetracking buffer state lines when the corresponding buffer is reloaded.
Closing in favor of #28875 |
Fixes #24972
When a buffer is reloaded, each client is detached from that buffer and then re-attached:
neovim/runtime/lua/vim/lsp.lua
Lines 557 to 561 in 4e5c633
When there’s only 1 LSP, the change tracking buffer state is deleted and re-created when the file is externally modified. This updates the
buf_state.lines
with the new buffer contents.neovim/runtime/lua/vim/lsp/_changetracking.lua
Line 205 in 4e5c633
If there are 2 LSPs attached, the buffer state is never deleted because the
refs
count never hits zero. So the buf state is never updated with the new buffer contents.neovim/runtime/lua/vim/lsp/_changetracking.lua
Lines 202 to 204 in 4e5c633