aboutsummaryrefslogtreecommitdiff
path: root/test/functional/fixtures/fake-lsp-server.lua
diff options
context:
space:
mode:
authorMathias Fußenegger <mfussenegger@users.noreply.github.com>2022-08-01 22:32:53 +0200
committerGitHub <noreply@github.com>2022-08-01 22:32:53 +0200
commite99de3f12f00662e8131fed9912792f6d43c4975 (patch)
tree45b75fa49f1dc134d6cf84f69a66c25a425d7fba /test/functional/fixtures/fake-lsp-server.lua
parent711ef4eac9e5126d37dd4acd1384b7df372d7315 (diff)
downloadrneovim-e99de3f12f00662e8131fed9912792f6d43c4975.tar.gz
rneovim-e99de3f12f00662e8131fed9912792f6d43c4975.tar.bz2
rneovim-e99de3f12f00662e8131fed9912792f6d43c4975.zip
fix(lsp): send didOpen if name changes on write (#19583)
`:saveas newName` changes the name of an existing buffer. Due to the buffer re-use it skips the lsp attach phase and immediately sends a `didSave` notification to the server. Servers get confused about this, because they expect a `didOpen` notification first. Closes https://github.com/neovim/neovim/issues/18688
Diffstat (limited to 'test/functional/fixtures/fake-lsp-server.lua')
-rw-r--r--test/functional/fixtures/fake-lsp-server.lua30
1 files changed, 26 insertions, 4 deletions
diff --git a/test/functional/fixtures/fake-lsp-server.lua b/test/functional/fixtures/fake-lsp-server.lua
index 0dc0c8c2db..aa47198f7a 100644
--- a/test/functional/fixtures/fake-lsp-server.lua
+++ b/test/functional/fixtures/fake-lsp-server.lua
@@ -67,10 +67,12 @@ local function expect_notification(method, params, ...)
local message = read_message()
assert_eq(method, message.method,
..., "expect_notification", "method")
- assert_eq(params, message.params,
- ..., "expect_notification", method, "params")
- assert_eq({jsonrpc = "2.0"; method=method, params=params}, message,
- ..., "expect_notification", "message")
+ if params then
+ assert_eq(params, message.params,
+ ..., "expect_notification", method, "params")
+ assert_eq({jsonrpc = "2.0"; method=method, params=params}, message,
+ ..., "expect_notification", "message")
+ end
end
local function expect_request(method, handler, ...)
@@ -257,6 +259,26 @@ function tests.basic_check_capabilities()
}
end
+function tests.text_document_save_did_open()
+ skeleton {
+ on_init = function()
+ return {
+ capabilities = {
+ textDocumentSync = {
+ save = true
+ }
+ }
+ }
+ end;
+ body = function()
+ notify('start')
+ expect_notification('textDocument/didOpen')
+ expect_notification('textDocument/didSave')
+ notify('shutdown')
+ end;
+ }
+end
+
function tests.text_document_sync_save_bool()
skeleton {
on_init = function()