wincent / command-t

⌨️ Fast file navigation for Neovim and Vim
BSD 2-Clause "Simplified" License
2.74k stars 317 forks source link

bug: `invalid option '%-100' to 'format'` #415

Closed wincent closed 1 year ago

wincent commented 1 year ago

I don't have a reliable repro for this yet, but this code[^formatting]: [^formatting]: Sorry about the formatting; my copy-paste brought in indent markers from Vim.

│ -- Right pad so that selection highlighting is shown across full width.
│ if width < 104 then
│ │ if #line > 99 then
│ │ │ -- No padding needed.
│ │ │ line = prefix .. line
│ │ else
│ │ │ line = prefix .. string.format('%-' .. (width - #prefix) .. 's', line)
│ │ end
│ else
│ │ -- Avoid: "invalid option" caused by format argument > 99.
│ │ line = prefix .. string.format('%-99s', line)
│ │ local diff = width - line:len()
│ │ if diff > 0 then
│ │ │ line = line .. string.rep(' ', diff)
│ │ end
│ end

can blow up with:

Error executing lua callback: ...command-t/lua/wincent/commandt/private/match_listing.lua:65: invalid option '%-100' to 'format'

if width is, say, 103, and #line is less 99 or less.

Very likely cause is this line:

https://github.com/wincent/command-t/blob/429b6b7b77764f5a660bd1d0c356029e32d71062/lua/wincent/commandt/private/match_listing.lua#L85

Rijalamagaha commented 1 year ago

Wow

trotzig commented 1 year ago

I can confirm the fix in 0f22018ef8da resolves the issue in one of my repos. 🎄🎉