nnn

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 1ba85825c58b04e7af71c2d8fb7c024918893ddd
parent 66f636de13c33dcb037f90c83b8a823b49b4c29e
Author: Arun <engineerarun@gmail.com>
Date:   Sun, 20 Aug 2023 17:59:30 +0530

Merge pull request #1711 from quantonganh/dup-first-char-macOS

Double-width icons can cause duplicated first characters in the filename on macOS
Diffstat:
Msrc/nnn.c | 14++++++++++++++
1 file changed, 14 insertions(+), 0 deletions(-)

diff --git a/src/nnn.c b/src/nnn.c @@ -131,6 +131,18 @@ #include "icons.h" #endif +#if defined(ICONS_ENABLED) && defined(__APPLE__) +/* + * For some reason, wcswidth returns 2 for certain icons on macOS + * leading to duplicated first characters in filenames when navigating. + * https://github.com/jarun/nnn/issues/1692 + * There might be a better way to fix it without requiring a refresh. + */ +#define macos_icons_hack() do { clrtoeol(); refresh(); } while(0) +#else +#define macos_icons_hack() +#endif + #ifdef TOURBIN_QSORT #include "qsort.h" #endif @@ -6520,6 +6532,7 @@ static void draw_line(int ncols) } move(2 + last - curscroll, 0); + macos_icons_hack(); printent(&pdents[last], ncols, FALSE); if (g_state.oldcolor && (pdents[cur].flags & DIR_OR_DIRLNK)) { @@ -6533,6 +6546,7 @@ static void draw_line(int ncols) } move(2 + cur - curscroll, 0); + macos_icons_hack(); printent(&pdents[cur], ncols, TRUE); /* Must reset e.g. no files in dir */