]> granicus.if.org Git - vim/commitdiff
patch 8.2.3461: cannot distinguish Normal and Terminal-Normal mode v8.2.3461
authorBram Moolenaar <Bram@vim.org>
Sat, 2 Oct 2021 15:34:55 +0000 (16:34 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 2 Oct 2021 15:34:55 +0000 (16:34 +0100)
Problem:    Cannot distinguish Normal and Terminal-Normal mode.
Solution:   Make mode() return "nt" for Terminal-Normal mode. (issue #8856)

runtime/doc/eval.txt
src/misc1.c
src/testdir/test_functions.vim
src/version.c

index 00ba2e41b43b2522ce2d4aabbd4f02f1d2c0c0c2..43aae40d4cbfeefa721f5a2f5773d34c6e342e45 100644 (file)
@@ -8061,7 +8061,7 @@ mode([expr])      Return a string that indicates the current mode.
                returned, otherwise only the first letter is returned.
                Also see |state()|.
 
-                  n        Normal, Terminal-Normal
+                  n        Normal
                   no       Operator-pending
                   nov      Operator-pending (forced characterwise |o_v|)
                   noV      Operator-pending (forced linewise |o_V|)
@@ -8070,6 +8070,7 @@ mode([expr])      Return a string that indicates the current mode.
                   niI      Normal using |i_CTRL-O| in |Insert-mode|
                   niR      Normal using |i_CTRL-O| in |Replace-mode|
                   niV      Normal using |i_CTRL-O| in |Virtual-Replace-mode|
+                  nt       Terminal-Normal (insert goes to Terminal-Job mode)
                   v        Visual by character
                   V        Visual by line
                   CTRL-V   Visual blockwise
index 1dd07f90673afd1e65cba339375a3119c6fa7c77..b4a4a8cc75f7b41b75c541de29e3f1c29b19c930 100644 (file)
@@ -712,6 +712,10 @@ f_mode(typval_T *argvars, typval_T *rettv)
            buf[1] = 'i';
            buf[2] = restart_edit;
        }
+#ifdef FEAT_TERMINAL
+       else if (term_in_normal_mode())
+           buf[1] = 't';
+#endif
     }
 
     // Clear out the minor mode when the argument is not a non-zero number or
index 9a4b5975f5cbfce4759140b7f452e62930bf0ff7..e8762aa6ced5c0a0eb30d5a41742b8a06fe2eeba 100644 (file)
@@ -874,6 +874,14 @@ func Test_mode()
   call assert_equal('c-ce', g:current_modes)
   " How to test Ex mode?
 
+  if has('terminal')
+    term
+    call feedkeys("\<C-W>N", 'xt')
+    call assert_equal('n', mode())
+    call assert_equal('nt', mode(1))
+    call feedkeys("aexit\<CR>", 'xt')
+  endif
+
   bwipe!
   iunmap <F2>
   xunmap <F2>
index 9331e3492eab6735deb83a912d69b6c5eb009a06..57865cdeda9d1566bbdf5150334ab59c166afc73 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3461,
 /**/
     3460,
 /**/