mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 20:01:27 +00:00
Fix broken statusbar when symlink name exceeds max cols
This commit is contained in:
parent
7cbc79a5fc
commit
943a7c13ac
18
src/nnn.c
18
src/nnn.c
|
@ -6037,7 +6037,7 @@ static bool set_time_type(int *presel)
|
||||||
|
|
||||||
static void statusbar(char *path)
|
static void statusbar(char *path)
|
||||||
{
|
{
|
||||||
int i = 0, extnlen = 0;
|
int i = 0, len = 0;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
pEntry pent = &pdents[cur];
|
pEntry pent = &pdents[cur];
|
||||||
|
|
||||||
|
@ -6051,8 +6051,8 @@ static void statusbar(char *path)
|
||||||
i = (int)(pent->nlen - 1);
|
i = (int)(pent->nlen - 1);
|
||||||
ptr = xextension(pent->name, i);
|
ptr = xextension(pent->name, i);
|
||||||
if (ptr)
|
if (ptr)
|
||||||
extnlen = i - (ptr - pent->name);
|
len = i - (ptr - pent->name);
|
||||||
if (!ptr || extnlen > 5 || extnlen < 2)
|
if (!ptr || len > 5 || len < 2)
|
||||||
ptr = "\b";
|
ptr = "\b";
|
||||||
} else
|
} else
|
||||||
ptr = "\b";
|
ptr = "\b";
|
||||||
|
@ -6106,16 +6106,14 @@ static void statusbar(char *path)
|
||||||
#endif
|
#endif
|
||||||
if (S_ISLNK(pent->mode)) {
|
if (S_ISLNK(pent->mode)) {
|
||||||
i = readlink(pent->name, g_buf, PATH_MAX);
|
i = readlink(pent->name, g_buf, PATH_MAX);
|
||||||
|
|
||||||
addstr(coolsize(i >= 0 ? i : pent->size)); /* Show symlink size */
|
addstr(coolsize(i >= 0 ? i : pent->size)); /* Show symlink size */
|
||||||
|
|
||||||
if (i > 1) { /* Show symlink target */
|
if (i > 1) { /* Show symlink target */
|
||||||
g_buf[i] = '\0';
|
int y;
|
||||||
#ifdef ICONS_ENABLED
|
|
||||||
addstr(" "MD_ARROW_FORWARD);
|
|
||||||
#else
|
|
||||||
addstr(" ->");
|
addstr(" ->");
|
||||||
#endif
|
getyx(stdscr, len, y);
|
||||||
|
i = MIN(i, xcols - y);
|
||||||
|
g_buf[i] = '\0';
|
||||||
addstr(g_buf);
|
addstr(g_buf);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue