From 0e89734640c45e5f97c50beb18fe414c10c776de Mon Sep 17 00:00:00 2001 From: Oscar Wallberg Date: Tue, 28 Apr 2026 14:21:17 +0200 Subject: [PATCH] fix(git): escape bracket name in :G output bufnr lookup --- lua/git/cmd.lua | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lua/git/cmd.lua b/lua/git/cmd.lua index 7dbad16..803c64d 100644 --- a/lua/git/cmd.lua +++ b/lua/git/cmd.lua @@ -109,13 +109,8 @@ local function run_in_split(worktree, args, conf) end end - -- Bracket naming so the buffer name doesn't pretend to be a real - -- file path (and doesn't collide with the `git://` URI - -- form used by the BufReadCmd loader). Reused on re-run so a - -- second `:G show HEAD` refreshes the existing buffer in place - -- instead of leaving a nameless duplicate behind. local name = "[git " .. table.concat(args, " ") .. "]" - local buf = vim.fn.bufnr(name) + local buf = vim.fn.bufnr("\\V" .. name) if buf == -1 or not vim.api.nvim_buf_is_loaded(buf) then buf = git.new_scratch() pcall(vim.api.nvim_buf_set_name, buf, name)