fix(picker.format): correcter max_width for truncpath

This commit is contained in:
Folke Lemaitre 2025-10-20 23:15:29 +02:00
parent a54477b0ac
commit a5d29646e5
No known key found for this signature in database
GPG key ID: 9B52594D560070AB
2 changed files with 7 additions and 3 deletions

View file

@ -480,8 +480,8 @@ function M:format(item)
local ctx = {
picker = self.picker,
item = item,
offset = vim.api.nvim_strwidth(text),
max_width = vim.api.nvim_win_get_width(self.win.win) - 5,
offset = 0,
max_width = vim.api.nvim_win_get_width(self.win.win),
}
line = Snacks.picker.highlight.resolve(line, ctx)

View file

@ -81,7 +81,11 @@ function M._filename(ctx)
end
local truncate = picker.opts.formatters.file.truncate
path = Snacks.picker.util.truncpath(path, ctx.max_width, { cwd = picker:cwd(), kind = truncate })
path = Snacks.picker.util.truncpath(
path,
ctx.max_width - Snacks.picker.highlight.offset(ret),
{ cwd = picker:cwd(), kind = truncate }
)
local base_hl = item.dir and "SnacksPickerDirectory" or "SnacksPickerFile"
local function is(prop)