From bd2f61c6c423bd5d61ad3eca237d8a5a82925dd8 Mon Sep 17 00:00:00 2001 From: hrsh7th Date: Tue, 19 Oct 2021 03:49:33 +0900 Subject: fix(lsp): fix cursor row after textEdits (#16038) --- test/functional/plugin/lsp_spec.lua | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'test/functional') diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index 81ef8a9733..ce50abb50d 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -1164,10 +1164,11 @@ describe('LSP', function() eq({ 2, 6 }, funcs.nvim_win_get_cursor(0)) end) - it('fix the cursor to the valid column if the content was removed', function() + it('fix the cursor to the valid col if the content was removed', function() funcs.nvim_win_set_cursor(0, { 2, 6 }) local edits = { - make_edit(1, 0, 1, 19, '') + make_edit(1, 0, 1, 6, ''), + make_edit(1, 6, 1, 19, '') } exec_lua('vim.lsp.util.apply_text_edits(...)', edits, 1) eq({ @@ -1180,6 +1181,19 @@ describe('LSP', function() eq({ 2, 0 }, funcs.nvim_win_get_cursor(0)) end) + it('fix the cursor to the valid row if the content was removed', function() + funcs.nvim_win_set_cursor(0, { 2, 6 }) + local edits = { + make_edit(1, 0, 1, 6, ''), + make_edit(0, 18, 5, 0, '') + } + exec_lua('vim.lsp.util.apply_text_edits(...)', edits, 1) + eq({ + 'First line of text'; + }, buf_lines(1)) + eq({ 1, 6 }, funcs.nvim_win_get_cursor(0)) + end) + it('fix the cursor row', function() funcs.nvim_win_set_cursor(0, { 3, 0 }) local edits = { -- cgit