diff --git a/src/nnn.c b/src/nnn.c index 6b0c1dc5..b847eeb9 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -367,12 +367,12 @@ typedef struct { uint_t rangesel : 1; /* Range selection on */ uint_t runctx : 3; /* The context in which plugin is to be run */ uint_t runplugin : 1; /* Choose plugin mode */ - uint_t selbm : 1; /* Select a bookmark from bookmarks directory */ + uint_t selbm : 2; /* Select bookmark dir and store type-to-nav */ uint_t selmode : 1; /* Set when selecting files */ uint_t stayonsel : 1; /* Disable auto-jump on select */ uint_t trash : 2; /* Trash method 0: rm -rf, 1: trash-cli, 2: gio trash */ uint_t uidgid : 1; /* Show owner and group info */ - uint_t reserved : 6; /* Adjust when adding/removing a field */ + uint_t reserved : 5; /* Adjust when adding/removing a field */ } runstate; /* Contexts or workspaces */ @@ -4988,14 +4988,17 @@ static size_t handle_bookmark(const char *bmark, char *newpath) bmark ? xstrsncpy(newpath, bmark, PATH_MAX) : (r = MSG_NOT_SET); else if (fd == '\r') { /* Visit bookmarks directory */ mkpath(cfgpath, toks[TOK_BM], newpath); - g_state.selbm = 1; + g_state.selbm = cfg.filtermode + 1; + cfg.filtermode = 1; } else if (!get_kv_val(bookmark, newpath, fd, maxbm, NNN_BMS)) r = MSG_INVALID_KEY; if (!r && chdir(newpath) == -1) { r = MSG_ACCESS; - if (g_state.selbm) + if (g_state.selbm) { + cfg.filtermode = g_state.selbm - 1; g_state.selbm = 0; + } } return r; @@ -6905,6 +6908,7 @@ nochange: /* Cannot descend in empty directories */ if (!ndents) { cd = FALSE; + cfg.filtermode = g_state.selbm - 1; g_state.selbm = g_state.runplugin = 0; goto begin; } @@ -6916,6 +6920,7 @@ nochange: S_ISLNK(pent->mode) ? (realpath(pent->name, newpath) && xstrsncpy(path, lastdir, PATH_MAX)) : mkpath(path, pent->name, newpath); + cfg.filtermode = g_state.selbm - 1; g_state.selbm = 0; } else mkpath(path, pent->name, newpath);