]> granicus.if.org Git - vim/commitdiff
patch 8.2.1772: cannot use CTRL-W <Down> to move out of a terminal window v8.2.1772
authorBram Moolenaar <Bram@vim.org>
Tue, 29 Sep 2020 19:23:25 +0000 (21:23 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 29 Sep 2020 19:23:25 +0000 (21:23 +0200)
Problem:    Cannot use CTRL-W <Down> to move out of a terminal window.
Solution:   Use special_to_buf() instead of mb_char2bytes(). (closes #7045)

src/terminal.c
src/testdir/test_terminal.vim
src/version.c

index 2043c8487ec019936f642a53e6fb93551a4ba0bd..867a0e3f3b30a40b0eefe92d7f237ff54a825e52 100644 (file)
@@ -2640,12 +2640,13 @@ if (raw_c > 0)
            }
            else if (termwinkey == 0 || c != termwinkey)
            {
-               char_u buf[MB_MAXBYTES + 2];
+               // space for CTRL-W, modifier, multi-byte char and NUL
+               char_u buf[1 + 3 + MB_MAXBYTES + 1];
 
                // Put the command into the typeahead buffer, when using the
                // stuff buffer KeyStuffed is set and 'langmap' won't be used.
                buf[0] = Ctrl_W;
-               buf[(*mb_char2bytes)(c, buf + 1) + 1] = NUL;
+               buf[special_to_buf(c, mod_mask, FALSE, buf + 1) + 1] = NUL;
                ins_typebuf(buf, REMAP_NONE, 0, TRUE, FALSE);
                ret = OK;
                goto theend;
index 207ef9afe3047502ccd81ba612590d5ebfa1a54d..676d864c72d840be4e27dbd36c956c00b87e14b6 100644 (file)
@@ -1379,6 +1379,23 @@ func Test_terminal_statusline()
   set statusline=
 endfunc
 
+func Test_terminal_window_focus()
+  let winid1 = win_getid()
+  terminal
+  let winid2 = win_getid()
+  call feedkeys("\<C-W>j", 'xt')
+  call assert_equal(winid1, win_getid())
+  call feedkeys("\<C-W>k", 'xt')
+  call assert_equal(winid2, win_getid())
+  " can use a cursor key here
+  call feedkeys("\<C-W>\<Down>", 'xt')
+  call assert_equal(winid1, win_getid())
+  call feedkeys("\<C-W>\<Up>", 'xt')
+  call assert_equal(winid2, win_getid())
+
+  bwipe!
+endfunc
+
 func Api_drop_common(options)
   call assert_equal(1, winnr('$'))
 
index d390212d8ae5a8591f5f47ed9455cb102c3e2a59..d5c8f3027786294f3be589970e7fbe5c70df0a9b 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1772,
 /**/
     1771,
 /**/