diff options
author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-04-14 13:01:08 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-14 13:01:08 -0700 |
commit | 9471b159362aabd35ef044a95e46520e8c110a57 (patch) | |
tree | 4be3e72e7c455aeb94ec0eaa0f663d14387f2a6d | |
parent | d9c7adc64c291f1a368c1417354332f72bdb66d6 (diff) | |
parent | 046991e4d5c6bc25ee11bbe28f0b685f00cf1d3d (diff) | |
download | rneovim-9471b159362aabd35ef044a95e46520e8c110a57.tar.gz rneovim-9471b159362aabd35ef044a95e46520e8c110a57.tar.bz2 rneovim-9471b159362aabd35ef044a95e46520e8c110a57.zip |
Merge pull request #14366 from mfussenegger/text-document-version-zero
lsp: Accept text document edits with version zero
-rw-r--r-- | runtime/lua/vim/lsp/util.lua | 1 | ||||
-rw-r--r-- | test/functional/plugin/lsp_spec.lua | 16 |
2 files changed, 9 insertions, 8 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 28a669778a..71ec85381b 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -470,6 +470,7 @@ function M.apply_text_document_edit(text_document_edit, index) -- `VersionedTextDocumentIdentifier`s version may be null -- https://microsoft.github.io/language-server-protocol/specification#versionedTextDocumentIdentifier if should_check_version and (text_document.version + and text_document.version > 0 and M.buf_versions[bufnr] and M.buf_versions[bufnr] > text_document.version) then print("Buffer ", text_document.uri, " newer than edits.") diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index 66b33cc9e1..557f8a206f 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -1124,14 +1124,14 @@ describe('LSP', function() '2nd line of 语text'; }, buf_lines(target_bufnr)) end) - it('correctly goes ahead with the edit if the version is vim.NIL', function() - -- we get vim.NIL when we decode json null value. - local json = exec_lua[[ - return vim.fn.json_decode("{ \"a\": 1, \"b\": null }") - ]] - eq(json.b, exec_lua("return vim.NIL")) - - exec_lua('vim.lsp.util.apply_text_document_edit(...)', text_document_edit(exec_lua("return vim.NIL"))) + it('always accepts edit with version = 0', function() + exec_lua([[ + local args = {...} + local bufnr = select(1, ...) + local text_edit = select(2, ...) + vim.lsp.util.buf_versions[bufnr] = 10 + vim.lsp.util.apply_text_document_edit(text_edit) + ]], target_bufnr, text_document_edit(0)) eq({ 'First ↥ 🤦 🦄 line of text'; '2nd line of 语text'; |