aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin/pack_spec.lua
diff options
context:
space:
mode:
authorEvgeni Chasnovski <evgeni.chasnovski@gmail.com>2025-11-13 15:45:48 +0200
committerEvgeni Chasnovski <evgeni.chasnovski@gmail.com>2025-11-17 12:46:22 +0200
commit9e2599df05896f43ee63a2eed55641ab0e2d2934 (patch)
tree6267f18a815f7b6d476cb21cde3fe3b9336f78e8 /test/functional/plugin/pack_spec.lua
parent5d258854a7fb7df08139c54f5dca1f7f8a490c75 (diff)
downloadrneovim-9e2599df05896f43ee63a2eed55641ab0e2d2934.tar.gz
rneovim-9e2599df05896f43ee63a2eed55641ab0e2d2934.tar.bz2
rneovim-9e2599df05896f43ee63a2eed55641ab0e2d2934.zip
fix(pack)!: adjust install confirm (no error on "No", show names)
Problem: Installation confirmation has several usability issues: - Choosing "No" results in a `vim.pack.add()` error. This was by design to ensure that all later code that *might* reference presumably installed plugin will not get executed. However, this is often too restrictive since there might be no such code (like if plugin's effects are automated in its 'plugin/' directory). Instead the potential code using not installed plugin will throw an error. No error on "No" will also be useful for planned lockfile repair. - List of soon-to-be-installed plugins doesn't mention plugin names. This might be confusing if plugins are installed under different name. Solution: Silently drop installation step if user chose "No" and show plugin names in confirmation text (together with their pretty aligned sources).
Diffstat (limited to 'test/functional/plugin/pack_spec.lua')
-rw-r--r--test/functional/plugin/pack_spec.lua18
1 files changed, 11 insertions, 7 deletions
diff --git a/test/functional/plugin/pack_spec.lua b/test/functional/plugin/pack_spec.lua
index 48155e2743..e75f586d38 100644
--- a/test/functional/plugin/pack_spec.lua
+++ b/test/functional/plugin/pack_spec.lua
@@ -387,18 +387,22 @@ describe('vim.pack', function()
end)
it('asks for installation confirmation', function()
- -- Do not confirm installation to see what happens
+ -- Do not confirm installation to see what happens (should not error)
mock_confirm(2)
- local err = pcall_err(exec_lua, function()
- vim.pack.add({ repos_src.basic })
+ exec_lua(function()
+ vim.pack.add({ repos_src.basic, { src = repos_src.defbranch, name = 'other-name' } })
end)
-
- matches('`basic`:\nInstallation was not confirmed', err)
eq(false, exec_lua('return pcall(require, "basic")'))
+ eq(false, exec_lua('return pcall(require, "defbranch")'))
+
+ local confirm_msg_lines = ([[
+ These plugins will be installed:
- local confirm_msg = 'These plugins will be installed:\n\n' .. repos_src.basic .. '\n'
- local ref_log = { { confirm_msg, 'Proceed? &Yes\n&No\n&Always', 1, 'Question' } }
+ basic from %s
+ other-name from %s]]):format(repos_src.basic, repos_src.defbranch)
+ local confirm_msg = vim.trim(vim.text.indent(0, confirm_msg_lines))
+ local ref_log = { { confirm_msg .. '\n', 'Proceed? &Yes\n&No\n&Always', 1, 'Question' } }
eq(ref_log, exec_lua('return _G.confirm_log'))
end)