Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
19 changes: 11 additions & 8 deletions lua/opencode/ui/base_picker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,14 @@ local function fzf_ui(opts)
return function(fzf_cb)
for _, item in ipairs(opts.items) do
local line_str = opts.format_fn(item):to_string()

-- For file preview support, append file:line:col format
-- fzf-lua's builtin previewer automatically parses this format
if opts.preview == 'file' and type(item) == 'table' then
local file_path = item.file_path or item.path or item.filename or item.file
local line = item.line or item.lnum
local col = item.column or item.col

if file_path then
-- fzf-lua parses "path:line:col:" format for preview positioning
local pos_info = file_path
Expand All @@ -254,7 +254,7 @@ local function fzf_ui(opts)
line_str = line_str .. nbsp .. pos_info
end
end

fzf_cb(line_str)
end
fzf_cb()
Expand Down Expand Up @@ -392,21 +392,20 @@ local function snacks_picker_ui(opts)
-- Determine if preview is enabled
local has_preview = opts.preview == 'file'

-- Choose layout preset based on preview
local layout_preset = has_preview and 'default' or 'select'
local title = type(opts.title) == 'function' and opts.title() or opts.title
---@cast title string

---@type snacks.picker.Config
local snack_opts = {
title = opts.title,
title = title,
layout = {
preset = layout_preset,
config = function(layout)
local width = opts.width and (opts.width + 3) or nil -- extra space for snacks UI
if not has_preview then
layout.layout.width = width
layout.layout.max_width = width
layout.layout.min_width = width
end
return layout
end,
},
finder = function()
Expand Down Expand Up @@ -437,6 +436,10 @@ local function snacks_picker_ui(opts)
-- Add file preview if enabled
if has_preview then
snack_opts.preview = 'file'
else
snack_opts.preview = function()
return false
end
end

snack_opts.win = snack_opts.win or {}
Expand Down