Skip to content

Commit ddcc145

Browse files
committed
fix: use nbsp separator for fzf-lua entries (not tab)
fzf-lua uses nbsp (U+2002 EN SPACE) as the standard separator between display text and file path info, not tab. The builtin previewer parses entries by splitting on utils.nbsp and extracting the path:line:col: portion. From fzf-lua/path.lua entry_to_file(): local parts = utils.strsplit(entry, utils.nbsp) for i = 1, #parts - 1 do if s:match(".-:%d+:") then break end idx0 = idx0 + #s + #utils.nbsp end return entry:sub(idx0), idx0 Changes: - Use nbsp (\xe2\x80\x82) instead of \t as separator - Update fn_fzf_index to split by nbsp - Use file_path (relative) before file (absolute) for correct resolution This fixes 'Unable to stat file' errors in preview.
1 parent e02416b commit ddcc145

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lua/opencode/ui/base_picker.lua

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,9 @@ local function fzf_ui(opts)
213213
previewer = opts.preview == 'file' and 'builtin' or nil,
214214
fn_fzf_index = function(line)
215215
-- Strip the appended file:line:col info before matching
216-
local display_part = line:match('^([^\t]+)') or line
216+
-- fzf-lua uses nbsp (U+2002 EN SPACE) as separator
217+
local nbsp = '\xe2\x80\x82'
218+
local display_part = line:match('^([^' .. nbsp .. ']+)') or line
217219
for i, item in ipairs(opts.items) do
218220
if opts.format_fn(item):to_string() == display_part then
219221
return i
@@ -232,7 +234,7 @@ local function fzf_ui(opts)
232234
-- For file preview support, append file:line:col format
233235
-- fzf-lua's builtin previewer automatically parses this format
234236
if opts.preview == 'file' and type(item) == 'table' then
235-
local file_path = item.file or item.file_path or item.path or item.filename
237+
local file_path = item.file_path or item.path or item.filename or item.file
236238
local line = item.line or item.lnum
237239
local col = item.column or item.col
238240

@@ -246,8 +248,10 @@ local function fzf_ui(opts)
246248
end
247249
pos_info = pos_info .. ':'
248250
end
249-
-- Append position info after tab separator (fzf-lua standard)
250-
line_str = line_str .. '\t' .. pos_info
251+
-- Append position info after nbsp separator (fzf-lua standard)
252+
-- nbsp is U+2002 EN SPACE, not regular tab
253+
local nbsp = '\xe2\x80\x82'
254+
line_str = line_str .. nbsp .. pos_info
251255
end
252256
end
253257

0 commit comments

Comments
 (0)