feat: nerd icons support#5
Conversation
feat: nerd icons support
kooler
left a comment
There was a problem hiding this comment.
Great addition! Please see a few small issues below.
| iconSpace := iconWidth + iconPadding | ||
| nameWidth := width - iconSpace - sizeWidth - timeWidth - 2 // 2 spaces between columns |
There was a problem hiding this comment.
it seems that name column shrinks by 1 char even when icons are disabled. When icons are disabled (the default), ResolveIcon returns "" and iconWidth stays 0, but iconPadding (1) is still subtracted.
The rendered row is 1 cell shorter than innerWidth, so the cursor/selection background highlight and the right border no longer reach the right edge.
| if icon == "" { | ||
| return 0 | ||
| } | ||
| return utf8.RuneCountInString(icon) |
There was a problem hiding this comment.
Many Nerd Font glyphs render as 2 terminal cells (East-Asian Wide / ambiguous-width in some terminals, and several nf-md-* / nf-custom-* glyphs are definitively 2 cells). utf8.RuneCountInString always returns 1 for a single-rune icon and will miscount those, causing the name column to be off by one.
Probably better to use runewidth.StringWidth(icon).
| if icon, ok := r.extIcons[strings.ToLower(ext)]; ok { | ||
| return icon | ||
| } |
There was a problem hiding this comment.
Setting a user extension to "" produces a broken row.
A user who wants to disable the default icon for .go by writing go = "" will get:
- ResolveIcon returns ""
- renderRow's if icon != "" branch is skipped, so no icon is prepended
- …but iconSpace still charges iconPadding (see issue Fix view/edit to support multi-word PAGER/EDITOR #1)
Lets pick one of:
- Treat empty as "fall back to default file icon" (if icon, ok := ...; ok && icon != "" { return icon }), OR
- Document explicitly that empty strings are reserved / not allowed in [icons.extensions].
| dist/ | ||
| QWEN.md | ||
| prompts/ | ||
| .gitignore |
There was a problem hiding this comment.
gitnoreception :-)
Probably a mistake.
feat: nerd icons support