Skip to content

Commit e0780fa

Browse files
authored
fix(chat): buffers with duplicate short_paths (#2665)
1 parent c609f04 commit e0780fa

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lua/codecompanion/interactions/chat/variables/buffer.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ function Variable.replace(prefix, message, bufnr)
121121
local result = message
122122

123123
-- Handle #{buffer:filename}{param} - display option with parameters
124-
local display_option_with_params_pattern = prefix .. "{buffer:([^}]*)}{[^}]*}"
125-
result = result:gsub(display_option_with_params_pattern, function(target)
124+
local display = prefix .. "{buffer:([^}]*)}{[^}]*}"
125+
result = result:gsub(display, function(target)
126126
local found = Variable._find_buffer(target)
127127
if found then
128128
local bufname = buf_utils.name_from_bufnr(found)

lua/codecompanion/providers/completion/init.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ local function _vars_cache_setup()
3535

3636
_vars_aug = api.nvim_create_augroup("codecompanion.chat.variables", { clear = true })
3737

38-
-- Invalidate the cache on the following events
38+
-- Keep track of the current buffer state across Neovim
3939
api.nvim_create_autocmd({
4040
"BufAdd",
4141
"BufDelete",
@@ -334,7 +334,7 @@ function M.variables()
334334
:map(function(buf)
335335
local name
336336
if name_counts[buf.name] > 1 then
337-
name = buf.short_path
337+
name = buf.relative_path
338338
else
339339
name = buf.name
340340
end

0 commit comments

Comments
 (0)