Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lua/opencode/model_picker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ function M.select(cb)
base_picker.pick({
title = 'Select model',
items = models,
width = config.ui.picker_width,
layout_opts = config.ui.picker,
format_fn = function(item, width)
local icon = item.icon or ''
Expand Down
2 changes: 1 addition & 1 deletion lua/opencode/types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
---@field persist_state boolean
---@field zoom_width number
---@field float OpencodeUIFloatConfig
---@field picker_width number|nil # Default width for all pickers (nil uses current window width)
---@field picker_width number|false|nil # Width for pickers. 0<w<=1 = fraction of screen; >1 = absolute columns; false = use picker backend defaults.
---@field display_model boolean
---@field display_context_size boolean
---@field display_cost boolean
Expand Down
37 changes: 36 additions & 1 deletion lua/opencode/ui/base_picker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -844,9 +844,44 @@ function M.pick(opts)
opts.width = config.ui.picker_width
end

-- picker_width = false means "use picker backend defaults, no override"
if opts.width == false then
opts.width = nil
end

-- Resolve relative width (0 < w <= 1) to absolute columns so that
-- format functions and all picker backends receive a consistent value.
if opts.width and opts.width > 0 and opts.width <= 1 then
opts.width = math.floor(vim.o.columns * opts.width)
end

-- When width is nil (picker_width = false or unset), derive a content width
-- from the picker backend's default window size so format functions can
-- produce correctly-sized output that fills the backend's content area.
local format_width = opts.width
if not format_width then
if picker_type == 'fzf' then
-- Read fzf-lua's effective winopts.width (respects user customization).
local fzf_win_width = 0.8
local ok, fzf_config = pcall(require, 'fzf-lua.config')
if ok and fzf_config and fzf_config.globals and fzf_config.globals.winopts then
fzf_win_width = fzf_config.globals.winopts.width or fzf_win_width
end
-- Resolve fraction to absolute columns
if fzf_win_width > 0 and fzf_win_width <= 1 then
fzf_win_width = math.floor(vim.o.columns * fzf_win_width)
end
-- Subtract the same chrome offset used when we set winopts ourselves (+8),
-- which covers borders, padding, and fzf's pointer indicator.
format_width = fzf_win_width - 8
else
format_width = math.floor(vim.o.columns * 0.8)
end
end

local original_format_fn = opts.format_fn
opts.format_fn = function(item)
return original_format_fn(item, opts.width)
return original_format_fn(item, format_width)
end

local title_str = type(opts.title) == 'function' and opts.title() or opts.title --[[@as string]]
Expand Down
2 changes: 1 addition & 1 deletion lua/opencode/ui/history_picker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function M.pick(callback)
end
end,
title = 'Select History Entry',
width = config.ui.picker_width or 100,
width = config.ui.picker_width,
layout_opts = config.ui.picker,
})
end
Expand Down
2 changes: 1 addition & 1 deletion lua/opencode/ui/reference_picker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ function M.pick()
end
end,
title = 'Code References (' .. #refs .. ')',
width = config.ui.picker_width or 100,
width = config.ui.picker_width,
preview = 'file',
layout_opts = config.ui.picker,
})
Expand Down
2 changes: 1 addition & 1 deletion lua/opencode/ui/session_picker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ function M.pick(sessions, callback)
actions = actions,
callback = callback,
title = 'Select A Session',
width = config.ui.picker_width or 100,
width = config.ui.picker_width,
layout_opts = config.ui.picker,
preview = 'custom',
---@param session table
Expand Down
2 changes: 1 addition & 1 deletion lua/opencode/ui/timeline_picker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function M.pick(messages, callback)
actions = actions,
callback = callback,
title = 'Timeline',
width = config.ui.picker_width or 100,
width = config.ui.picker_width,
layout_opts = config.ui.picker,
})
end
Expand Down
Loading