aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMathias Fußenegger <mfussenegger@users.noreply.github.com>2021-02-20 04:20:42 +0100
committerGitHub <noreply@github.com>2021-02-19 22:20:42 -0500
commit1caf58578c6e4b30c18fa56804dd905b5472b460 (patch)
tree918cd3895cae191da2ed50c6114b0dfa4c8ffb8c /test
parentb2fcfc65b7181cfb519ce1f827cb62f1120de5a0 (diff)
downloadrneovim-1caf58578c6e4b30c18fa56804dd905b5472b460.tar.gz
rneovim-1caf58578c6e4b30c18fa56804dd905b5472b460.tar.bz2
rneovim-1caf58578c6e4b30c18fa56804dd905b5472b460.zip
lsp: Fix text edits operating on the last line of a document (#13677)
`lines` can be empty, in which case `#lines[#lines]` failed with an error: lsp/util.lua:214: attempt to get length of a nil value
Diffstat (limited to 'test')
-rw-r--r--test/functional/plugin/lsp_spec.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index 981e2a96a8..cec306eb39 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -1032,6 +1032,20 @@ describe('LSP', function()
'å ä ɧ 汉语 ↥ 🤦 🦄';
}, buf_lines(1))
end)
+ it('applies text edits at the end of the document', function()
+ local edits = {
+ make_edit(5, 0, 5, 0, "foobar");
+ }
+ exec_lua('vim.lsp.util.apply_text_edits(...)', edits, 1)
+ eq({
+ 'First line of text';
+ 'Second line of text';
+ 'Third line of text';
+ 'Fourth line of text';
+ 'å å ɧ 汉语 ↥ 🤦 🦄';
+ 'foobar';
+ }, buf_lines(1))
+ end)
describe('with LSP end line after what Vim considers to be the end line', function()
it('applies edits when the last linebreak is considered a new line', function()