Skip to content

Commit 7b3aab1

Browse files
committed
chore(context):fix warnings
1 parent aeaa79b commit 7b3aab1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lua/opencode/ui/completion/context.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ local function create_context_item(name, type, available, documentation, icon, a
1919
return {
2020
label = label,
2121
kind = 'context',
22-
kind_icon = icon or (available and '' or ''),
22+
kind_icon = icon or (available and icons.get('status_on') or icons.get('status_off')),
2323
detail = name,
2424
documentation = documentation or (available and name or 'Enable ' .. name .. ' for this message'),
2525
insert_text = '',
@@ -69,7 +69,7 @@ local function format_cursor_data(cursor_data)
6969
return 'No cursor data available.'
7070
end
7171

72-
local filetype = context.context.current_file.extension
72+
local filetype = context.context.current_file and context.context.current_file.extension
7373
local parts = {
7474
'Line: ' .. (cursor_data.line or 'N/A'),
7575
(cursor_data.column or ''),
@@ -119,7 +119,8 @@ local function add_selection_items(ctx)
119119
}
120120

121121
for i, selection in ipairs(ctx.selections or {}) do
122-
local label = 'Selection ' .. (selection.file and vim.fn.fnamemodify(selection.file.path, ':t')) or i
122+
local label =
123+
string.format('Selection %d %s (%s)', i, selection.file and selection.file.name or 'Untitled', selection.lines)
123124
table.insert(
124125
items,
125126
create_context_item(label, 'selection_item', true, format_selection(selection), icons.get('selection'), selection)
@@ -211,7 +212,7 @@ local context_source = {
211212
end
212213

213214
local type = item.data.type
214-
local context_cfg = vim.deepcopy(state.current_context_config) or {}
215+
local context_cfg = vim.deepcopy(state.current_context_config or {})
215216
if not context_cfg or not context_cfg[type] then
216217
context_cfg[type] = vim.deepcopy(config.context[type])
217218
end

0 commit comments

Comments
 (0)