mirror of
https://github.com/harivansh-afk/forge.nvim.git
synced 2026-04-15 08:03:44 +00:00
Fix fzf-lua ansi_from_hl compatibility
Wrap the highlighted segment render path so forge only consumes the first return value from fzf-lua's ansi_from_hl helper, and add a regression spec covering the newer two-value return shape. Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
parent
09463c08b7
commit
f3f66ae560
2 changed files with 52 additions and 1 deletions
|
|
@ -23,7 +23,7 @@ local function render(segments)
|
||||||
local parts = {}
|
local parts = {}
|
||||||
for _, seg in ipairs(segments) do
|
for _, seg in ipairs(segments) do
|
||||||
if seg[2] then
|
if seg[2] then
|
||||||
table.insert(parts, utils.ansi_from_hl(seg[2], seg[1]))
|
table.insert(parts, (utils.ansi_from_hl(seg[2], seg[1])))
|
||||||
else
|
else
|
||||||
table.insert(parts, seg[1])
|
table.insert(parts, seg[1])
|
||||||
end
|
end
|
||||||
|
|
|
||||||
51
spec/fzf_picker_spec.lua
Normal file
51
spec/fzf_picker_spec.lua
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
vim.opt.runtimepath:prepend(vim.fn.getcwd())
|
||||||
|
|
||||||
|
package.preload['fzf-lua.utils'] = function()
|
||||||
|
return {
|
||||||
|
ansi_from_hl = function(_, text)
|
||||||
|
return text, '\27[38;2;1;2;3m'
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
local captured
|
||||||
|
|
||||||
|
package.preload['fzf-lua'] = function()
|
||||||
|
return {
|
||||||
|
fzf_exec = function(lines, opts)
|
||||||
|
captured = { lines = lines, opts = opts }
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
describe('fzf picker', function()
|
||||||
|
before_each(function()
|
||||||
|
captured = nil
|
||||||
|
package.loaded['forge'] = nil
|
||||||
|
package.loaded['forge.picker.fzf'] = nil
|
||||||
|
vim.g.forge = nil
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('renders highlighted segments when ansi_from_hl returns extra values', function()
|
||||||
|
local picker = require('forge.picker.fzf')
|
||||||
|
picker.pick({
|
||||||
|
prompt = 'PRs> ',
|
||||||
|
entries = {
|
||||||
|
{
|
||||||
|
display = {
|
||||||
|
{ '#42', 'ForgeNumber' },
|
||||||
|
{ ' fix api drift ' },
|
||||||
|
{ 'alice 1h', 'ForgeDim' },
|
||||||
|
},
|
||||||
|
value = '42',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
actions = {},
|
||||||
|
picker_name = 'pr',
|
||||||
|
})
|
||||||
|
|
||||||
|
assert.is_not_nil(captured)
|
||||||
|
assert.same({ '1\t#42 fix api drift alice 1h' }, captured.lines)
|
||||||
|
assert.equals('PRs> ', captured.opts.prompt)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue