diff options
author | Mathias Fußenegger <mfussenegger@users.noreply.github.com> | 2024-06-04 17:21:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-04 17:21:37 +0200 |
commit | 2e6d295f799c27372e5c0c44727fa613c81717fd (patch) | |
tree | 73691edf3ee84eb23f703ae20aeb29ee141af1a0 /runtime/lua/vim/lsp/util.lua | |
parent | b66106a46c5c6180c7f80852a8c822b400e73100 (diff) | |
download | rneovim-2e6d295f799c27372e5c0c44727fa613c81717fd.tar.gz rneovim-2e6d295f799c27372e5c0c44727fa613c81717fd.tar.bz2 rneovim-2e6d295f799c27372e5c0c44727fa613c81717fd.zip |
fix(lsp): account for changedtick version gap on modified reset (#29170)
Follow up to https://github.com/neovim/neovim/pull/28943
Fixes https://github.com/neovim/neovim/issues/29163
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r-- | runtime/lua/vim/lsp/util.lua | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index b33f6ccf69..3215b40d1d 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -502,6 +502,11 @@ function M.apply_text_document_edit(text_document_edit, index, offset_encoding) should_check_version = false end + -- changedtick increases on save but server only receives version updates + -- on line changes (via didChange) + -- This allows a gap of 1 to account for the servers outdated view + local version_offset = vim.b[bufnr].modified and 0 or 1 + -- `VersionedTextDocumentIdentifier`s version may be null -- https://microsoft.github.io/language-server-protocol/specification#versionedTextDocumentIdentifier if @@ -509,7 +514,7 @@ function M.apply_text_document_edit(text_document_edit, index, offset_encoding) and ( text_document.version and text_document.version > 0 - and vim.b[bufnr].changedtick > text_document.version + and vim.b[bufnr].changedtick > (text_document.version + version_offset) ) then print('Buffer ', text_document.uri, ' newer than edits.') |