diff options
| author | 2018-08-08 04:57:49 +0530 | |
|---|---|---|
| committer | 2018-08-08 04:57:49 +0530 | |
| commit | bf36462a2b2141d0454d13d98074ce4e7e706fd1 (patch) | |
| tree | a9ec872db1d2cf31fc5459c49544badab2308b4b | |
| parent | 38a4a2cf8b0b05a033381250e2bd05d1ec0f0115 (diff) | |
| download | nnn-bf36462a2b2141d0454d13d98074ce4e7e706fd1.tar.gz | |
Implement dir auto-select in nav-as-you-type mode.
If only one entry matches regex filter and it it a directory, cd into it.
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | nnn.1 | 2 | ||||
| -rw-r--r-- | nnn.c | 15 |
3 files changed, 19 insertions, 0 deletions
@@ -276,6 +276,8 @@ If `nnn` is invoked as root or the environment variable `NNN_SHOW_HIDDEN` is set In this mode directories are opened in filter mode, allowing continuous navigation. Works best with the **arrow keys**. +In case of only one match and it's a directory, `nnn` auto selects the directory and enters it in this mode. + #### File indicators The following indicators are used in the detail view: @@ -206,6 +206,8 @@ is invoked as root or the environment variable \fBNNN_SHOW_HIDDEN\fR is set the .Pp In the \fInavigate-as-you-type\fR mode directories are opened in filter mode, allowing continuous navigation. Works best with the \fBarrow keys\fR. +.br +In case of only one match and it's a directory, `nnn` auto selects the directory and enters it in this mode. .Sh MULTI-COPY MODE The absolute path of a single file can be copied to clipboard by pressing \fI^K\fR if NNN_COPIER is set (see ENVIRONMENT section below). @@ -1161,6 +1161,21 @@ filterentries(char *path) ndents = total; if (matches(pln) == -1) continue; + + /* If the only match is a dir, auto-select and cd into it */ + if (cfg.filtermode && ndents == 1 && S_ISDIR(dents[0].mode)) { + *ch = KEY_ENTER; + cur = 0; + goto end; + } + + /* + * redraw() should be above the auto-select optimization, for + * the case where there's an issue with dir auto-select, say, + * due to a permission problem. The transition is jumpy in + * case of such an error. However, we optimize for successful + * cases where the dir has permissions. This skips a redraw(). + */ redraw(path); printprompt(ln); } |