fix(lsp): use buffer scheme for files not stored on disk (#22407)

Sending `didOpen` with a `file` scheme causes problems with some
language servers because they expect the file to exist on disk.

See https://github.com/microsoft/language-server-protocol/pull/1679
This commit is contained in:
Mathias Fußenegger
2023-03-01 15:33:13 +01:00
committed by GitHub
parent d66832c76d
commit 896d672736
3 changed files with 70 additions and 30 deletions

View File

@@ -272,6 +272,7 @@ function tests.text_document_save_did_open()
end;
body = function()
notify('start')
expect_notification('textDocument/didClose')
expect_notification('textDocument/didOpen')
expect_notification('textDocument/didSave')
notify('shutdown')
@@ -292,6 +293,8 @@ function tests.text_document_sync_save_bool()
end;
body = function()
notify('start')
expect_notification('textDocument/didClose')
expect_notification('textDocument/didOpen')
expect_notification('textDocument/didSave', {textDocument = { uri = "file://" }})
notify('shutdown')
end;
@@ -313,6 +316,8 @@ function tests.text_document_sync_save_includeText()
end;
body = function()
notify('start')
expect_notification('textDocument/didClose')
expect_notification('textDocument/didOpen')
expect_notification('textDocument/didSave', {
textDocument = {
uri = "file://"
@@ -459,7 +464,7 @@ function tests.basic_check_buffer_open()
textDocument = {
languageId = "";
text = table.concat({"testing"; "123"}, "\n") .. '\n';
uri = "file://";
uri = "buffer://";
version = 0;
};
})
@@ -486,13 +491,13 @@ function tests.basic_check_buffer_open_and_change()
textDocument = {
languageId = "";
text = table.concat({"testing"; "123"}, "\n") .. '\n';
uri = "file://";
uri = "buffer://";
version = 0;
};
})
expect_notification('textDocument/didChange', {
textDocument = {
uri = "file://";
uri = "buffer://";
version = 3;
};
contentChanges = {
@@ -522,13 +527,13 @@ function tests.basic_check_buffer_open_and_change_noeol()
textDocument = {
languageId = "";
text = table.concat({"testing"; "123"}, "\n");
uri = "file://";
uri = "buffer://";
version = 0;
};
})
expect_notification('textDocument/didChange', {
textDocument = {
uri = "file://";
uri = "buffer://";
version = 3;
};
contentChanges = {
@@ -557,13 +562,13 @@ function tests.basic_check_buffer_open_and_change_multi()
textDocument = {
languageId = "";
text = table.concat({"testing"; "123"}, "\n") .. '\n';
uri = "file://";
uri = "buffer://";
version = 0;
};
})
expect_notification('textDocument/didChange', {
textDocument = {
uri = "file://";
uri = "buffer://";
version = 3;
};
contentChanges = {
@@ -572,7 +577,7 @@ function tests.basic_check_buffer_open_and_change_multi()
})
expect_notification('textDocument/didChange', {
textDocument = {
uri = "file://";
uri = "buffer://";
version = 4;
};
contentChanges = {
@@ -602,13 +607,13 @@ function tests.basic_check_buffer_open_and_change_multi_and_close()
textDocument = {
languageId = "";
text = table.concat({"testing"; "123"}, "\n") .. '\n';
uri = "file://";
uri = "buffer://";
version = 0;
};
})
expect_notification('textDocument/didChange', {
textDocument = {
uri = "file://";
uri = "buffer://";
version = 3;
};
contentChanges = {
@@ -617,7 +622,7 @@ function tests.basic_check_buffer_open_and_change_multi_and_close()
})
expect_notification('textDocument/didChange', {
textDocument = {
uri = "file://";
uri = "buffer://";
version = 4;
};
contentChanges = {
@@ -626,7 +631,7 @@ function tests.basic_check_buffer_open_and_change_multi_and_close()
})
expect_notification('textDocument/didClose', {
textDocument = {
uri = "file://";
uri = "buffer://";
};
})
expect_notification("finish")
@@ -660,13 +665,13 @@ function tests.basic_check_buffer_open_and_change_incremental()
textDocument = {
languageId = "";
text = table.concat({"testing"; "123"}, "\n") .. '\n';
uri = "file://";
uri = "buffer://";
version = 0;
};
})
expect_notification('textDocument/didChange', {
textDocument = {
uri = "file://";
uri = "buffer://";
version = 3;
};
contentChanges = {
@@ -703,13 +708,13 @@ function tests.basic_check_buffer_open_and_change_incremental_editing()
textDocument = {
languageId = "";
text = table.concat({"testing"; "123"}, "\n");
uri = "file://";
uri = "buffer://";
version = 0;
};
})
expect_notification('textDocument/didChange', {
textDocument = {
uri = "file://";
uri = "buffer://";
version = 3;
};
contentChanges = {