diff options
author | butwerenotthereyet <58348703+butwerenotthereyet@users.noreply.github.com> | 2020-01-02 06:06:11 -0800 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2020-01-02 06:06:11 -0800 |
commit | cbc8d72fde4b19176028490934ff7a447afe523c (patch) | |
tree | 80c962c8c65b356e55b9a55e0f67c1ba2b24b78d /src/nvim/normal.c | |
parent | 2c62b2fc56b6b86a930356ccf48ba8fb189a7654 (diff) | |
download | rneovim-cbc8d72fde4b19176028490934ff7a447afe523c.tar.gz rneovim-cbc8d72fde4b19176028490934ff7a447afe523c.tar.bz2 rneovim-cbc8d72fde4b19176028490934ff7a447afe523c.zip |
tabpage: track last-used tabpage #11626
In a multi-window scenario, it is possible to return focus to the last
accessed window via n_CTRL-W_p. However, in the case of a multi-tab
scenario, there was previously no way to return focus to the last
accessed *tab*. Here, that ability is added via n_g<tab>.
Additionally, the index of the previous tab is exposed via
tabpagenr('#'), mirroring the existing functionality of winnr('#').
Diffstat (limited to 'src/nvim/normal.c')
-rw-r--r-- | src/nvim/normal.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 9c707a6fdc..d0b9fd4589 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -6312,9 +6312,7 @@ static void nv_gomark(cmdarg_T *cap) } } -/* - * Handle CTRL-O, CTRL-I, "g;" and "g," commands. - */ +// Handle CTRL-O, CTRL-I, "g;", "g,", and "CTRL-Tab" commands. static void nv_pcmark(cmdarg_T *cap) { pos_T *pos; @@ -6322,11 +6320,16 @@ static void nv_pcmark(cmdarg_T *cap) const bool old_KeyTyped = KeyTyped; // getting file may reset it if (!checkclearopq(cap->oap)) { - if (cap->cmdchar == 'g') + if (cap->cmdchar == TAB && mod_mask == MOD_MASK_CTRL) { + goto_tabpage_lastused(); + return; + } + if (cap->cmdchar == 'g') { pos = movechangelist((int)cap->count1); - else + } else { pos = movemark((int)cap->count1); - if (pos == (pos_T *)-1) { /* jump to other file */ + } + if (pos == (pos_T *)-1) { // jump to other file curwin->w_set_curswant = true; check_cursor(); } else if (pos != NULL) /* can jump */ @@ -7059,6 +7062,11 @@ static void nv_g_cmd(cmdarg_T *cap) if (!checkclearop(oap)) goto_tabpage(-(int)cap->count1); break; + case TAB: + if (!checkclearop(oap)) { + goto_tabpage_lastused(); + } + break; case '+': case '-': /* "g+" and "g-": undo or redo along the timeline */ |