mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(lsp): send didClose on buffer rename (#22623)
Subset of https://github.com/neovim/neovim/pull/22407 that was reverted in https://github.com/neovim/neovim/pull/22604 If a buffer is renamed sending `didClose` for the old buffer helps ensure the language server doesn't keep a stale document in memory.
This commit is contained in:
parent
865d8d4720
commit
23dc2a59b6
@ -1,3 +1,4 @@
|
|||||||
|
---@diagnostic disable: invisible
|
||||||
local default_handlers = require('vim.lsp.handlers')
|
local default_handlers = require('vim.lsp.handlers')
|
||||||
local log = require('vim.lsp.log')
|
local log = require('vim.lsp.log')
|
||||||
local lsp_rpc = require('vim.lsp.rpc')
|
local lsp_rpc = require('vim.lsp.rpc')
|
||||||
@ -1592,6 +1593,11 @@ local function text_document_did_save_handler(bufnr)
|
|||||||
local name = api.nvim_buf_get_name(bufnr)
|
local name = api.nvim_buf_get_name(bufnr)
|
||||||
local old_name = changetracking._get_and_set_name(client, bufnr, name)
|
local old_name = changetracking._get_and_set_name(client, bufnr, name)
|
||||||
if old_name and name ~= old_name then
|
if old_name and name ~= old_name then
|
||||||
|
client.notify('textDocument/didClose', {
|
||||||
|
textDocument = {
|
||||||
|
uri = vim.uri_from_fname(old_name),
|
||||||
|
},
|
||||||
|
})
|
||||||
client.notify('textDocument/didOpen', {
|
client.notify('textDocument/didOpen', {
|
||||||
textDocument = {
|
textDocument = {
|
||||||
version = 0,
|
version = 0,
|
||||||
|
@ -272,6 +272,7 @@ function tests.text_document_save_did_open()
|
|||||||
end;
|
end;
|
||||||
body = function()
|
body = function()
|
||||||
notify('start')
|
notify('start')
|
||||||
|
expect_notification('textDocument/didClose')
|
||||||
expect_notification('textDocument/didOpen')
|
expect_notification('textDocument/didOpen')
|
||||||
expect_notification('textDocument/didSave')
|
expect_notification('textDocument/didSave')
|
||||||
notify('shutdown')
|
notify('shutdown')
|
||||||
|
Loading…
Reference in New Issue
Block a user