jarun/nnn

Nerd fonts cause misaligned columns in detail mode with names first

erhhung opened this issue · 5 comments

Environment details (Put x in the checkbox along with the information)

  • Operating System: macOS Sonoma 14.2.1
  • Desktop Environment:
  • Terminal Emulator: iTerm2 3.4.23
  • Terminal Font: DroidSansM Nerd Font Regular 16, no ligatures
  • Shell: Bash 5.2.26
  • Custom desktop opener (if applicable):
  • Program options used: NNN_OPTS=acdeoEHQR
  • Configuration options set:
  • Plugins are installed: NNN_PLUG=v:-preview-tui;y:-cbcopy-mac
  • Issue exists on nnn master

Exact steps to reproduce the issue

  1. Create a build with Nerd Fonts and name first options enabled:
    make clean; make O_NERD=1 O_NAMEFIRST=1; ./nnn
image
  1. Press d to hide the detail columns:
image

Notice that the file size column has not been properly cleared.

  1. If, instead, build without either above options, columns are aligned:

make clean; make O_NERD=1; ./nnn

image

make clean; make O_NAMEFIRST=1; ./nnn

image

Other observations

  1. Changing the terminal font in iTerm to other Nerd fonts made no difference.
  2. I'm aware that some Nerd font glyphs yield double the character widths even though they visually take up only a single cell, but I'm not sure if there's a consistent way to account for that during rendering of the columns.

I vaguely remember a similar issue, either from myself or by another user on the issue tracker. But I can't reproduce this locally on master so it seems to be a platform/font/terminal issue.

Likely cause by macos wcswidth returning 2 width for some icons: #1692 (comment)

Thanks. I suppose updating the namefirst patch to use the added macro might fix this then.

EDIT: hmm the macro we added doesn't seem to apply to where the issue shows up in the name first patch. Only thing I can think of to work around this would be to hardcode the wcswidth for the offending icons. I won't be doing that... (Is the upstream library aware of this issue and is there any chance it will be fixed?)

Only thing I can think of to work around this would be to hardcode the wcswidth for the offending icons.

There was also this patch (#1694) which fixed the issue by clearing the whole screen IIRC. It "worked" but had pretty bad performance impact though. Maybe this gives you some ideas.