Skip to content

Commit

Permalink
Merge pull request #1711 from quantonganh/dup-first-char-macOS
Browse files Browse the repository at this point in the history
Double-width icons can cause duplicated first characters in the filename on macOS
  • Loading branch information
jarun committed Aug 20, 2023
2 parents 66f636d + d220c50 commit 1ba8582
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/nnn.c
Expand Up @@ -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
Expand Down Expand Up @@ -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)) {
Expand All @@ -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 */
Expand Down

0 comments on commit 1ba8582

Please sign in to comment.