aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/eval.txt3
-rw-r--r--src/nvim/state.c4
-rw-r--r--src/nvim/testdir/test_functions.vim12
3 files changed, 19 insertions, 0 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 38bbd66ea2..3efe651dfe 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -5774,6 +5774,9 @@ mode([expr]) Return a string that indicates the current mode.
This is useful in the 'statusline' option or when used
with |remote_expr()| In most other places it always returns
"c" or "n".
+ Note that in the future more modes and more specific modes may
+ be added. It's better not to compare the whole string but only
+ the leading character(s).
Also see |visualmode()|.
msgpackdump({list}) *msgpackdump()*
diff --git a/src/nvim/state.c b/src/nvim/state.c
index bfd73050c3..e6eeaac8d0 100644
--- a/src/nvim/state.c
+++ b/src/nvim/state.c
@@ -162,6 +162,10 @@ char *get_mode(void)
buf[1] = 'o';
// to be able to detect force-linewise/blockwise/characterwise operations
buf[2] = (char)motion_force;
+ } else if (restart_edit == 'I' || restart_edit == 'R'
+ || restart_edit == 'V') {
+ buf[1] = 'i';
+ buf[2] = (char)restart_edit;
}
}
diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim
index 7dc9f31ce7..bfe13d6b2d 100644
--- a/src/nvim/testdir/test_functions.vim
+++ b/src/nvim/testdir/test_functions.vim
@@ -556,6 +556,18 @@ func Test_mode()
call assert_equal('n', mode(0))
call assert_equal('n', mode(1))
+ " i_CTRL-O
+ exe "normal i\<C-O>:call Save_mode()\<Cr>\<Esc>"
+ call assert_equal("n-niI", g:current_modes)
+
+ " R_CTRL-O
+ exe "normal R\<C-O>:call Save_mode()\<Cr>\<Esc>"
+ call assert_equal("n-niR", g:current_modes)
+
+ " gR_CTRL-O
+ exe "normal gR\<C-O>:call Save_mode()\<Cr>\<Esc>"
+ call assert_equal("n-niV", g:current_modes)
+
" How to test operator-pending mode?
call feedkeys("v", 'xt')