diff options
author | Mathias Fußenegger <mfussenegger@users.noreply.github.com> | 2024-06-07 11:36:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-07 11:36:46 +0200 |
commit | 6e45cd7f0026ee33b8c397b810dcfe5b4678bbd8 (patch) | |
tree | 3903f0cca53f9fbd9a47242b011ac69bda14610a /test/functional/plugin/lsp_spec.lua | |
parent | 6c7677e5d274da7e477518aa29b0faa862e61627 (diff) | |
download | rneovim-6e45cd7f0026ee33b8c397b810dcfe5b4678bbd8.tar.gz rneovim-6e45cd7f0026ee33b8c397b810dcfe5b4678bbd8.tar.bz2 rneovim-6e45cd7f0026ee33b8c397b810dcfe5b4678bbd8.zip |
fix(lsp): revert buf_versions deprecation/replacement (#29217)
* Revert "fix(lsp): account for changedtick version gap on modified reset (#29170)"
This reverts commit 2e6d295f799c27372e5c0c44727fa613c81717fd.
* Revert "refactor(lsp): replace util.buf_versions with changedtick (#28943)"
This reverts commit 5c33815448e11b514678f39cecc74e68131d4628.
Diffstat (limited to 'test/functional/plugin/lsp_spec.lua')
-rw-r--r-- | test/functional/plugin/lsp_spec.lua | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index 23f6b733d5..0cf84b50c2 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -255,7 +255,7 @@ describe('LSP', function() return end local expected_handlers = { - { NIL, {}, { method = 'shutdown', bufnr = 1, client_id = 1, version = 2 } }, + { NIL, {}, { method = 'shutdown', bufnr = 1, client_id = 1 } }, { NIL, {}, { method = 'test', client_id = 1 } }, } test_rpc_server { @@ -948,11 +948,7 @@ describe('LSP', function() it('should forward ContentModified to callback', function() local expected_handlers = { { NIL, {}, { method = 'finish', client_id = 1 } }, - { - { code = -32801 }, - NIL, - { method = 'error_code_test', bufnr = 1, client_id = 1, version = 2 }, - }, + { { code = -32801 }, NIL, { method = 'error_code_test', bufnr = 1, client_id = 1 } }, } local client --- @type vim.lsp.Client test_rpc_server { @@ -982,7 +978,7 @@ describe('LSP', function() it('should track pending requests to the language server', function() local expected_handlers = { { NIL, {}, { method = 'finish', client_id = 1 } }, - { NIL, {}, { method = 'slow_request', bufnr = 1, client_id = 1, version = 2 } }, + { NIL, {}, { method = 'slow_request', bufnr = 1, client_id = 1 } }, } local client --- @type vim.lsp.Client test_rpc_server { @@ -1049,7 +1045,7 @@ describe('LSP', function() it('should clear pending and cancel requests on reply', function() local expected_handlers = { { NIL, {}, { method = 'finish', client_id = 1 } }, - { NIL, {}, { method = 'slow_request', bufnr = 1, client_id = 1, version = 2 } }, + { NIL, {}, { method = 'slow_request', bufnr = 1, client_id = 1 } }, } local client --- @type vim.lsp.Client test_rpc_server { @@ -1088,7 +1084,7 @@ describe('LSP', function() it('should trigger LspRequest autocmd when requests table changes', function() local expected_handlers = { { NIL, {}, { method = 'finish', client_id = 1 } }, - { NIL, {}, { method = 'slow_request', bufnr = 1, client_id = 1, version = 2 } }, + { NIL, {}, { method = 'slow_request', bufnr = 1, client_id = 1 } }, } local client --- @type vim.lsp.Client test_rpc_server { @@ -1368,7 +1364,6 @@ describe('LSP', function() }, bufnr = 2, client_id = 1, - version = 2, }, }, { NIL, {}, { method = 'start', client_id = 1 } }, @@ -2122,6 +2117,7 @@ describe('LSP', function() 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, nil, 'utf-16') ]], target_bufnr, @@ -2133,13 +2129,16 @@ describe('LSP', function() }, buf_lines(target_bufnr)) end) it('skips the edit if the version of the edit is behind the local buffer ', function() - local apply_edit_mocking_current_version = function(edit) + local apply_edit_mocking_current_version = function(edit, versionedBuf) exec_lua( [[ local args = {...} + local versionedBuf = args[2] + vim.lsp.util.buf_versions[versionedBuf.bufnr] = versionedBuf.currentVersion vim.lsp.util.apply_text_document_edit(args[1], nil, 'utf-16') ]], - edit + edit, + versionedBuf ) end @@ -2151,17 +2150,17 @@ describe('LSP', function() eq(baseText, buf_lines(target_bufnr)) -- Apply an edit for an old version, should skip - apply_edit_mocking_current_version(text_document_edit(1)) + apply_edit_mocking_current_version( + text_document_edit(2), + { currentVersion = 7, bufnr = target_bufnr } + ) eq(baseText, buf_lines(target_bufnr)) -- no change -- Sanity check that next version to current does apply change - apply_edit_mocking_current_version(text_document_edit(exec_lua( - [[ - local bufnr = ... - return vim.b[bufnr].changedtick - ]], - target_bufnr - ))) + apply_edit_mocking_current_version( + text_document_edit(8), + { currentVersion = 7, bufnr = target_bufnr } + ) eq({ 'First ↥ 🤦 🦄 line of text', '2nd line of 语text', @@ -2240,6 +2239,18 @@ describe('LSP', function() } vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, lines) + + local update_changed_tick = function() + vim.lsp.util.buf_versions[bufnr] = vim.api.nvim_buf_get_var(bufnr, 'changedtick') + end + + update_changed_tick() + vim.api.nvim_buf_attach(bufnr, false, { + on_changedtick = function() + update_changed_tick() + end + }) + return {bufnr, vim.api.nvim_buf_get_var(bufnr, 'changedtick')} ]] |