Skip to content

Commit ff8f103

Browse files
sudo-teeCopilot
andcommitted
Update lua/opencode/ui/reference_picker.lua
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 3d8ba85 commit ff8f103

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

lua/opencode/ui/reference_picker.lua

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ local function is_valid_file_reference(path, context)
1818
return false
1919
end
2020

21-
-- Must have extension and exist
22-
return path:match('%.[%w]+$') and vim.fn.filereadable(path) == 1
21+
return (path:match('%.[%w]+$') and vim.fn.filereadable(path) == 1) or false
2322
end
2423

2524
---@class CodeReference
@@ -105,7 +104,7 @@ local function parse_references_with_pattern(text, pattern, message_id)
105104
local context_start = math.max(1, match_start - 30)
106105
local context = text:sub(context_start, match_end + 10)
107106

108-
if is_valid_file_reference(path, context) then
107+
if path and is_valid_file_reference(path, context) then
109108
local line, column, end_line = parse_position_info(line_str, col_or_end_str, end_line_str)
110109
local ref = create_code_reference(path, line, column, end_line, message_id, match_start, match_end)
111110
table.insert(references, ref)
@@ -177,8 +176,8 @@ function M.collect_references()
177176
local seen = {}
178177
local deduplicated = {}
179178
for _, ref in ipairs(all_references) do
180-
local relative_path = vim.fn.fnamemodify(ref.file_path, ':~:.')
181-
local dedup_key = relative_path .. ':' .. (ref.line or 0)
179+
local normalized_path = vim.fn.fnamemodify(ref.file_path, ':p')
180+
local dedup_key = normalized_path .. ':' .. (ref.line or 0)
182181
if not seen[dedup_key] then
183182
seen[dedup_key] = true
184183
table.insert(deduplicated, ref)

0 commit comments

Comments
 (0)