Skip to content

Commit 517c656

Browse files
fix: promtp_guard: Use the defined function to get the status icon
1 parent 8f16faf commit 517c656

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

lua/opencode/ui/topbar.lua

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,41 +46,39 @@ local function create_winbar_text(description, model_info, mode_info, show_guard
4646
-- Calculate how many visible characters we have
4747
-- Format: " [GUARD] description padding model_info MODE "
4848
-- Where [GUARD] is optional (1 char + 1 space = 2 visible chars)
49-
50-
local guard_prefix = ''
49+
50+
local guard_icon = ''
5151
local guard_visible_width = 0
52-
5352
if show_guard_indicator then
54-
local guard_icon = icons.get('status_off')
55-
guard_prefix = string.format('%%#OpencodeGuardDenied#%s%%* ', guard_icon)
53+
guard_icon = prompt_guard_indicator.get_formatted()
5654
guard_visible_width = 2 -- icon + space
5755
end
58-
56+
5957
-- Total available width for all content
6058
local total_width = win_width
61-
59+
6260
-- Calculate used width: leading space + guard + trailing space + model + mode
6361
local mode_info_str = get_mode_highlight() .. mode_info .. '%*'
6462
local mode_visible_width = #mode_info
6563
local model_visible_width = #model_info
66-
64+
6765
-- Reserve space: 1 (leading) + guard_visible_width + 1 (space before description) + 1 (space before model) + model + mode
6866
local reserved_width = 1 + guard_visible_width + 1 + 1 + model_visible_width + mode_visible_width
69-
67+
7068
-- Available width for description and padding
7169
local available_for_desc = total_width - reserved_width
72-
70+
7371
-- Truncate description if needed
7472
if #description > available_for_desc then
7573
description = description:sub(1, math.max(1, available_for_desc - 4)) .. '...'
7674
end
77-
75+
7876
-- Calculate padding to right-align model and mode
7977
local desc_and_padding_width = available_for_desc
8078
local padding_width = desc_and_padding_width - #description
8179
local padding = string.rep(' ', math.max(0, padding_width))
82-
83-
return string.format(' %s%s%s%s %s', guard_prefix, description, padding, model_info, mode_info_str)
80+
81+
return string.format(' %s%s%s%s %s', guard_icon, description, padding, model_info, mode_info_str)
8482
end
8583

8684
local function update_winbar_highlights(win_id)

0 commit comments

Comments
 (0)