mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #14366 from mfussenegger/text-document-version-zero
lsp: Accept text document edits with version zero
This commit is contained in:
commit
9471b15936
@ -470,6 +470,7 @@ function M.apply_text_document_edit(text_document_edit, index)
|
|||||||
-- `VersionedTextDocumentIdentifier`s version may be null
|
-- `VersionedTextDocumentIdentifier`s version may be null
|
||||||
-- https://microsoft.github.io/language-server-protocol/specification#versionedTextDocumentIdentifier
|
-- https://microsoft.github.io/language-server-protocol/specification#versionedTextDocumentIdentifier
|
||||||
if should_check_version and (text_document.version
|
if should_check_version and (text_document.version
|
||||||
|
and text_document.version > 0
|
||||||
and M.buf_versions[bufnr]
|
and M.buf_versions[bufnr]
|
||||||
and M.buf_versions[bufnr] > text_document.version) then
|
and M.buf_versions[bufnr] > text_document.version) then
|
||||||
print("Buffer ", text_document.uri, " newer than edits.")
|
print("Buffer ", text_document.uri, " newer than edits.")
|
||||||
|
@ -1124,14 +1124,14 @@ describe('LSP', function()
|
|||||||
'2nd line of 语text';
|
'2nd line of 语text';
|
||||||
}, buf_lines(target_bufnr))
|
}, buf_lines(target_bufnr))
|
||||||
end)
|
end)
|
||||||
it('correctly goes ahead with the edit if the version is vim.NIL', function()
|
it('always accepts edit with version = 0', function()
|
||||||
-- we get vim.NIL when we decode json null value.
|
exec_lua([[
|
||||||
local json = exec_lua[[
|
local args = {...}
|
||||||
return vim.fn.json_decode("{ \"a\": 1, \"b\": null }")
|
local bufnr = select(1, ...)
|
||||||
]]
|
local text_edit = select(2, ...)
|
||||||
eq(json.b, exec_lua("return vim.NIL"))
|
vim.lsp.util.buf_versions[bufnr] = 10
|
||||||
|
vim.lsp.util.apply_text_document_edit(text_edit)
|
||||||
exec_lua('vim.lsp.util.apply_text_document_edit(...)', text_document_edit(exec_lua("return vim.NIL")))
|
]], target_bufnr, text_document_edit(0))
|
||||||
eq({
|
eq({
|
||||||
'First ↥ 🤦 🦄 line of text';
|
'First ↥ 🤦 🦄 line of text';
|
||||||
'2nd line of 语text';
|
'2nd line of 语text';
|
||||||
|
Loading…
Reference in New Issue
Block a user