jarun / nnn

n³ The unorthodox terminal file manager
BSD 2-Clause "Simplified" License
18.5k stars 743 forks source link

Nerd fonts cause misaligned columns in detail mode with names first #1802

Closed erhhung closed 3 months ago

erhhung commented 5 months ago

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

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
  2. Press d to hide the detail columns:

    image

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

  3. 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.
luukvbaal commented 5 months ago

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.

N-R-K commented 5 months ago

Likely cause by macos wcswidth returning 2 width for some icons: https://github.com/jarun/nnn/issues/1692#issuecomment-1637153406

luukvbaal commented 5 months ago

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?)

N-R-K commented 5 months ago

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 (https://github.com/jarun/nnn/pull/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.

KlzXS commented 3 months ago

Added to Tracker. Closing here.

Since day 1 there have been problems with alignment with icons. This is an old issue and seems deeply connected to the way terminals render characters. In all this time no one has been able to either solve the issue universally or provide proof that it can't be done. We'll just leave it there in case someone want to give it another shot.