aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorJaehwang Jung <tomtomjhj@gmail.com>2024-02-25 00:47:34 +0900
committerGitHub <noreply@github.com>2024-02-24 16:47:34 +0100
commit8addd27504e698da62176824209ae2d3d24247c0 (patch)
tree3f435ee7baf43ff291867bf7871271886c3bdaca /test/functional
parent04f723f1a5780196a5356d3bbca17438c572ffa1 (diff)
downloadrneovim-8addd27504e698da62176824209ae2d3d24247c0.tar.gz
rneovim-8addd27504e698da62176824209ae2d3d24247c0.tar.bz2
rneovim-8addd27504e698da62176824209ae2d3d24247c0.zip
fix(lsp): when renaming directory, check path prefix of buffer names (#27603)
For example, when renaming /path/to/dir, buffers like fern://drawer/file:///path/to/dir, /path/to/dir123 should not be matched.
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/plugin/lsp_spec.lua41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index be9a8342ff..b57fb268e1 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -2515,6 +2515,47 @@ describe('LSP', function()
os.remove(new_dir)
end)
+ it('Does not touch buffers that do not match path prefix', function()
+ local old = tmpname()
+ local new = tmpname()
+ os.remove(old)
+ os.remove(new)
+ helpers.mkdir_p(old)
+
+ local result = exec_lua(
+ [[
+ local old = select(1, ...)
+ local new = select(2, ...)
+
+ local old_prefixed = 'explorer://' .. old
+ local old_suffixed = old .. '.bak'
+ local new_prefixed = 'explorer://' .. new
+ local new_suffixed = new .. '.bak'
+
+ local old_prefixed_buf = vim.fn.bufadd(old_prefixed)
+ local old_suffixed_buf = vim.fn.bufadd(old_suffixed)
+ local new_prefixed_buf = vim.fn.bufadd(new_prefixed)
+ local new_suffixed_buf = vim.fn.bufadd(new_suffixed)
+
+ vim.lsp.util.rename(old, new)
+
+ return
+ vim.api.nvim_buf_is_valid(old_prefixed_buf) and
+ vim.api.nvim_buf_is_valid(old_suffixed_buf) and
+ vim.api.nvim_buf_is_valid(new_prefixed_buf) and
+ vim.api.nvim_buf_is_valid(new_suffixed_buf) and
+ vim.api.nvim_buf_get_name(old_prefixed_buf) == old_prefixed and
+ vim.api.nvim_buf_get_name(old_suffixed_buf) == old_suffixed and
+ vim.api.nvim_buf_get_name(new_prefixed_buf) == new_prefixed and
+ vim.api.nvim_buf_get_name(new_suffixed_buf) == new_suffixed
+ ]],
+ old,
+ new
+ )
+ eq(true, result)
+
+ os.remove(new)
+ end)
it(
'Does not rename file if target exists and ignoreIfExists is set or overwrite is false',
function()