Minor refactor

This commit is contained in:
Arun Prakash Jana 2020-06-28 00:09:48 +05:30
parent 06651f3f00
commit 90cf84186a
No known key found for this signature in database
GPG Key ID: A75979F35C080412
2 changed files with 129 additions and 128 deletions

View File

@ -28,7 +28,7 @@ It runs smoothly on the Pi, [Termux](https://www.youtube.com/watch?v=AbaauM7gUJw
## Black magic! :dark_sunglasses:
- Load, sort, filter thousands of files instantly
- Instantly load, sort, filter thousands of files
- Type to navigate with automatic dir selection
- Never lose context - start where you quit `nnn`
- find/fd/grep/ripgrep/fzf from `nnn` and list in `nnn`

View File

@ -5617,6 +5617,7 @@ nochange:
mkpath(path, pdents[cur].name, newpath);
DPRINTF_S(newpath);
/* Visit directory */
if (pdents[cur].flags & DIR_OR_LINK_TO_DIR) {
if (chdir(newpath) == -1) {
printwarn(&presel);
@ -5634,9 +5635,12 @@ nochange:
}
DPRINTF_U(sb.st_mode);
switch (sb.st_mode & S_IFMT) {
case S_IFREG:
{
/* Do not open non-regular files */
if (!S_ISREG(sb.st_mode)) {
printwait(messages[MSG_UNSUPPORTED], &presel);
goto nochange;
}
/* If opened as vim plugin and Enter/^M pressed, pick */
if (g_state.picker && sel == SEL_GOIN) {
appendfpath(newpath, mkpath(path, pdents[cur].name, newpath));
@ -5664,8 +5668,11 @@ nochange:
? (presel = FILTER) : (watch = TRUE);
xstrsncpy(lastname, pdents[cur].name, NAME_MAX + 1);
goto begin;
} else if (cfg.nonavopen)
goto nochange; /* Open file disabled on right arrow or `l` */
}
/* Open file disabled on right arrow or `l` */
if (cfg.nonavopen)
goto nochange;
}
/* Handle plugin selection mode */
@ -5680,8 +5687,7 @@ nochange:
if (chdir(path) == -1
|| !run_selected_plugin(&path, pdents[cur].name,
runfile, &lastname,
&lastdir)) {
runfile, &lastname, &lastdir)) {
DPRINTF_S("plugin failed!");
}
@ -5699,7 +5705,7 @@ nochange:
}
if (cfg.useeditor
#ifdef FILE_MIME_OPTS
#ifdef FILE_MIME
&& get_output(g_buf, CMD_LEN_MAX, "file", FILE_MIME_OPTS, newpath, FALSE)
&& is_prefix(g_buf, "text/", 5)
#else
@ -5759,11 +5765,6 @@ nochange:
if (g_state.autonext && cur != ndents - 1)
move_cursor((cur + 1) % ndents, 0);
continue;
}
default:
printwait(messages[MSG_UNSUPPORTED], &presel);
goto nochange;
}
case SEL_NEXT: // fallthrough
case SEL_PREV: // fallthrough
case SEL_PGDN: // fallthrough