changeset 25854:2d0bea8aed33 v8.2.3461

patch 8.2.3461: cannot distinguish Normal and Terminal-Normal mode Commit: https://github.com/vim/vim/commit/72406a4bd2896915b6f541e26d41521a59b1f846 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Oct 2 16:34:55 2021 +0100 patch 8.2.3461: cannot distinguish Normal and Terminal-Normal mode Problem: Cannot distinguish Normal and Terminal-Normal mode. Solution: Make mode() return "nt" for Terminal-Normal mode. (issue https://github.com/vim/vim/issues/8856)
author Bram Moolenaar <Bram@vim.org>
date Sat, 02 Oct 2021 17:45:03 +0200
parents 6cb99ee013ca
children 8f877a00d685
files runtime/doc/eval.txt src/misc1.c src/testdir/test_functions.vim src/version.c
diffstat 4 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -8061,7 +8061,7 @@ mode([expr])	Return a string that indica
 		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 indica
 		   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
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -712,6 +712,10 @@ f_mode(typval_T *argvars, typval_T *rett
 	    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
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -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>
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    3461,
+/**/
     3460,
 /**/
     3459,