aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornotomo <notomo.motono@gmail.com>2020-06-04 21:48:48 +0900
committerGitHub <noreply@github.com>2020-06-04 08:48:48 -0400
commitac5a3f2c56775040a1b7de438cfd592c0dc26400 (patch)
tree1f1d56ffffc3631bc5083058b03e5677cda27f79
parentb807de36d4236014ec426aa81eb2952c0b027c64 (diff)
downloadrneovim-ac5a3f2c56775040a1b7de438cfd592c0dc26400.tar.gz
rneovim-ac5a3f2c56775040a1b7de438cfd592c0dc26400.tar.bz2
rneovim-ac5a3f2c56775040a1b7de438cfd592c0dc26400.zip
lua: fix behavior when split empty string (#12429)
* lua: fix behavior when split empty string * test: lsp.util.apply_text_edits with an empty edit
-rw-r--r--runtime/lua/vim/shared.lua2
-rw-r--r--test/functional/lua/vim_spec.lua1
-rw-r--r--test/functional/plugin/lsp_spec.lua3
3 files changed, 4 insertions, 2 deletions
diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua
index 5dc8d6dc10..384d22cb89 100644
--- a/runtime/lua/vim/shared.lua
+++ b/runtime/lua/vim/shared.lua
@@ -79,7 +79,7 @@ function vim.gsplit(s, sep, plain)
end
return function()
- if done or s == '' then
+ if done or (s == '' and sep == '') then
return
end
if sep == '' then
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index 61bc3e1e3c..aa0b3d822b 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -244,6 +244,7 @@ describe('lua stdlib', function()
{ "axaby", "ab?", false, { '', 'x', 'y' } },
{ "f v2v v3v w2w ", "([vw])2%1", false, { 'f ', ' v3v ', ' ' } },
{ "", "", false, {} },
+ { "", "a", false, { '' } },
{ "x*yz*oo*l", "*", true, { 'x', 'yz', 'oo', 'l' } },
}
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index ea0f52c85b..479741d717 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -800,13 +800,14 @@ describe('LSP', function()
make_edit(0, 0, 0, 0, {"123"});
make_edit(1, 0, 1, 1, {"2"});
make_edit(2, 0, 2, 2, {"3"});
+ make_edit(3, 2, 3, 4, {""});
}
exec_lua('vim.lsp.util.apply_text_edits(...)', edits, 1)
eq({
'123First line of text';
'2econd line of text';
'3ird line of text';
- 'Fourth line of text';
+ 'Foth line of text';
'å å ɧ 汉语 ↥ 🤦 🦄';
}, buf_lines(1))
end)