From eff01b7620cf4dfea4c033cd90421d999b75fe1b Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Thu, 6 Nov 2025 20:13:17 +0200 Subject: [PATCH] fix(pack): use more correct URI for confirmation buffer name Problem: Confirmation buffer is named with `nvim-pack://` as scheme prefix and uses buffer id (needed for in-process LSP) as one an entry in the "hierarchical part". Solution: Use `nvim://pack-confirm#` format with a more ubiquitous `nvim://` prefix and buffer id at the end as the optional fragment. --- runtime/doc/lua-plugin.txt | 4 ++-- runtime/lua/vim/pack.lua | 2 +- runtime/lua/vim/pack/_lsp.lua | 2 +- test/functional/plugin/pack_spec.lua | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/runtime/doc/lua-plugin.txt b/runtime/doc/lua-plugin.txt index 5c4fc052c8..14704c7d9d 100644 --- a/runtime/doc/lua-plugin.txt +++ b/runtime/doc/lua-plugin.txt @@ -282,8 +282,8 @@ mappings to a specific action by invoking `vim.lsp.buf.code_action()` with the < Example: See `runtime/lua/vim/pack/_lsp.lua` for how vim.pack defines an -in-process LSP server to provide interactive features in its `nvim-pack://` -buffer. +in-process LSP server to provide interactive features in its +`nvim://pack-confirm` buffer. ============================================================================== Troubleshooting *lua-plugin-troubleshooting* diff --git a/runtime/lua/vim/pack.lua b/runtime/lua/vim/pack.lua index ec2c1cd294..fb4d65b892 100644 --- a/runtime/lua/vim/pack.lua +++ b/runtime/lua/vim/pack.lua @@ -923,7 +923,7 @@ end local function show_confirm_buf(lines, on_finish) -- Show buffer in a separate tabpage local bufnr = api.nvim_create_buf(true, true) - api.nvim_buf_set_name(bufnr, 'nvim-pack://' .. bufnr .. '/confirm-update') + api.nvim_buf_set_name(bufnr, 'nvim://pack-confirm#' .. bufnr) api.nvim_buf_set_lines(bufnr, 0, -1, false, lines) vim.cmd.sbuffer({ bufnr, mods = { tab = vim.fn.tabpagenr() } }) local tab_id = api.nvim_get_current_tabpage() diff --git a/runtime/lua/vim/pack/_lsp.lua b/runtime/lua/vim/pack/_lsp.lua index 7bcec41d38..7af48d529b 100644 --- a/runtime/lua/vim/pack/_lsp.lua +++ b/runtime/lua/vim/pack/_lsp.lua @@ -20,7 +20,7 @@ function methods.shutdown(_, callback) end local get_confirm_bufnr = function(uri) - return tonumber(uri:match('^nvim%-pack://(%d+)/confirm%-update$')) + return tonumber(uri:match('^nvim://pack%-confirm#(%d+)$')) end local group_header_pattern = '^# (%S+)' diff --git a/test/functional/plugin/pack_spec.lua b/test/functional/plugin/pack_spec.lua index 58dca1223e..5662e173d0 100644 --- a/test/functional/plugin/pack_spec.lua +++ b/test/functional/plugin/pack_spec.lua @@ -987,7 +987,7 @@ describe('vim.pack', function() local confirm_bufnr = api.nvim_get_current_buf() local confirm_winnr = api.nvim_get_current_win() local confirm_tabpage = api.nvim_get_current_tabpage() - eq(api.nvim_buf_get_name(0), 'nvim-pack://' .. confirm_bufnr .. '/confirm-update') + eq(api.nvim_buf_get_name(0), 'nvim://pack-confirm#' .. confirm_bufnr) -- Adjust lines for a more robust screenshot testing local fetch_src = repos_src.fetch @@ -1037,10 +1037,10 @@ describe('vim.pack', function() short_hashes.fetch_new_prev = git_get_short_hash('main~', 'fetch') hashes.semver_head = git_get_hash('v0.3.0', 'semver') - local tab_name = 'n' .. (t.is_os('win') and ':' or '') .. '//2/confirm-update' + local tab_name = 'n' .. (t.is_os('win') and ':' or '') .. '//pack-confirm#2' local screen_lines = { - ('{24: [No Name] }{5: %s }{2:%s }{24:X}|'):format( + ('{24: [No Name] }{5: %s }{2:%s }{24:X}|'):format( tab_name, t.is_os('win') and '' or ' ' ),