Skip to content

Commit 882d02e

Browse files
committed
patch 8.1.0974: cannot switch from terminal window to previous tabpage
Problem: Cannot switch from terminal window to previous tabpage. Solution: Make CTRL-W gT move to previous tabpage.
1 parent cd62512 commit 882d02e

4 files changed

Lines changed: 24 additions & 9 deletions

File tree

runtime/doc/terminal.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ Special in the terminal window: *CTRL-W_.* *CTRL-W_N*
8181
evaluating an expression.
8282
CTRL-W CTRL-C ends the job, see below |t_CTRL-W_CTRL-C|
8383
CTRL-W gt go to next tabpage, same as `gt`
84+
CTRL-W gT go to previous tabpage, same as `gT`
8485

8586
See option 'termwinkey' for specifying another key instead of CTRL-W that
8687
will work like CTRL-W. However, typing 'termwinkey' twice sends 'termwinkey'

src/testdir/test_terminal.vim

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,10 +1569,14 @@ func Test_terminal_termwinsize_mininmum()
15691569
endfunc
15701570

15711571
func Test_terminal_termwinkey()
1572+
" make three tabpages, terminal in the middle
1573+
0tabnew
1574+
tabnext
1575+
tabnew
1576+
tabprev
15721577
call assert_equal(1, winnr('$'))
1578+
call assert_equal(2, tabpagenr())
15731579
let thiswin = win_getid()
1574-
tabnew
1575-
tabnext
15761580

15771581
let buf = Run_shell_in_terminal({})
15781582
let termwin = bufwinid(buf)
@@ -1582,11 +1586,16 @@ func Test_terminal_termwinkey()
15821586
call feedkeys("\<C-W>w", 'tx')
15831587
call assert_equal(termwin, win_getid())
15841588

1585-
let tnr = tabpagenr()
15861589
call feedkeys("\<C-L>gt", "xt")
1587-
call assert_notequal(tnr, tabpagenr())
1590+
call assert_equal(3, tabpagenr())
1591+
tabprev
1592+
call assert_equal(2, tabpagenr())
1593+
call assert_equal(termwin, win_getid())
1594+
1595+
call feedkeys("\<C-L>gT", "xt")
1596+
call assert_equal(1, tabpagenr())
15881597
tabnext
1589-
call assert_equal(tnr, tabpagenr())
1598+
call assert_equal(2, tabpagenr())
15901599
call assert_equal(termwin, win_getid())
15911600

15921601
let job = term_getjob(buf)
@@ -1596,6 +1605,8 @@ func Test_terminal_termwinkey()
15961605
set termwinkey&
15971606
tabnext
15981607
tabclose
1608+
tabprev
1609+
tabclose
15991610
endfunc
16001611

16011612
func Test_terminal_out_err()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,8 @@ static char *(features[]) =
779779

780780
static int included_patches[] =
781781
{ /* Add new patch number below this line */
782+
/**/
783+
974,
782784
/**/
783785
973,
784786
/**/

src/window.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,7 @@ do_window(
8787
#endif
8888
char_u cbuf[40];
8989

90-
if (Prenum == 0)
91-
Prenum1 = 1;
92-
else
93-
Prenum1 = Prenum;
90+
Prenum1 = Prenum == 0 ? 1 : Prenum;
9491

9592
#ifdef FEAT_CMDWIN
9693
# define CHECK_CMDWIN \
@@ -588,6 +585,10 @@ do_window(
588585
goto_tabpage((int)Prenum);
589586
break;
590587

588+
case 'T': // CTRL-W gT: go to previous tab page
589+
goto_tabpage(-(int)Prenum1);
590+
break;
591+
591592
default:
592593
beep_flush();
593594
break;

0 commit comments

Comments
 (0)