Skip to content

Commit 01d4fae

Browse files
authored
refactor(rules): don't expand the path in the chat (#2903)
Co-authored-by: Oli Morris <[email protected]>
1 parent ecb41c1 commit 01d4fae

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

  • lua/codecompanion/interactions/chat/rules

lua/codecompanion/interactions/chat/rules/init.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,9 @@ function Rules:read_files(paths)
142142
local ok, content = pcall(file.read, path)
143143

144144
if ok then
145-
-- Find the parser for this file
145+
-- Find the parser and original path for this file
146146
local file_parser = nil
147+
local original_path = nil
147148
for _, file_spec in ipairs(self.files) do
148149
if type(file_spec) == "table" and file_spec.path then
149150
local normalized_spec_path = vim.fs.normalize(file_spec.path)
@@ -159,14 +160,20 @@ function Rules:read_files(paths)
159160
-- Exact path match
160161
if path == normalized_spec_path then
161162
file_parser = file_spec.parser
163+
original_path = file_spec.path
162164
break
163165
end
164166
end
167+
elseif type(file_spec) == "string" then
168+
if path == vim.fs.normalize(file_spec) then
169+
original_path = file_spec
170+
break
171+
end
165172
end
166173
end
167174

168175
table.insert(files, {
169-
name = path,
176+
name = original_path or path,
170177
content = content,
171178
path = path,
172179
filename = vim.fn.fnamemodify(path, ":t"),

0 commit comments

Comments
 (0)