aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorAndreas Johansson <ndreas@users.noreply.github.com>2020-05-17 19:47:14 +0200
committerGitHub <noreply@github.com>2020-05-17 13:47:14 -0400
commit4fbbe1c957509393563be9492d03b9e95bb08e6a (patch)
tree3b2b4d93df88f1c7a95ae589f60f692162fc65f3 /test/functional
parentae5bd0454ee4ed3bdbf22e953a216449ca34dd46 (diff)
downloadrneovim-4fbbe1c957509393563be9492d03b9e95bb08e6a.tar.gz
rneovim-4fbbe1c957509393563be9492d03b9e95bb08e6a.tar.bz2
rneovim-4fbbe1c957509393563be9492d03b9e95bb08e6a.zip
lsp: Handle end lines in apply_text_edits (#12314)
If the LSP sends an end line that is larger than what nvim considers to be the last line, you get an Index out of bounds error when fetching the line from nvim, a change that was introduced in #12223. This change removes the strict indexing and checks the return value from nvim_buf_get_lines.
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/plugin/lsp_spec.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index 62dee7df90..f41a5323a8 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -831,6 +831,30 @@ describe('LSP', function()
'å ä ɧ 汉语 ↥ 🤦 🦄';
}, 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()
+ local edits = {
+ make_edit(0, 0, 5, 0, {"All replaced"});
+ }
+ exec_lua('vim.lsp.util.apply_text_edits(...)', edits, 1)
+ eq({'All replaced'}, buf_lines(1))
+ end)
+ it('applies edits when the end line is 2 larger than vim\'s', function()
+ local edits = {
+ make_edit(0, 0, 6, 0, {"All replaced"});
+ }
+ exec_lua('vim.lsp.util.apply_text_edits(...)', edits, 1)
+ eq({'All replaced'}, buf_lines(1))
+ end)
+ it('applies edits with a column offset', function()
+ local edits = {
+ make_edit(0, 0, 5, 2, {"All replaced"});
+ }
+ exec_lua('vim.lsp.util.apply_text_edits(...)', edits, 1)
+ eq({'All replaced'}, buf_lines(1))
+ end)
+ end)
end)
describe('apply_text_document_edit', function()