From 04ba81ddba047604e7df4a5a9a451d5059950e48 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 29 Jul 2021 07:12:11 +0800 Subject: [PATCH] vim-patch:8.2.3236: mode() does not indicate using CTRL-O in Select mode Problem: mode() does not indicate using CTRL-O in Select mode. Solution: Use "vs" and similar. (closes vim/vim#8640) https://github.com/vim/vim/commit/eaf3f36168f85c8e0ab7083cd996b9fbe937045d --- runtime/doc/eval.txt | 4 ++++ src/nvim/globals.h | 2 ++ src/nvim/normal.c | 2 -- src/nvim/state.c | 3 +++ src/nvim/testdir/test_functions.vim | 10 ++++++++++ 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index e32691dfb4..2b6e3aff29 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -6350,6 +6350,10 @@ mode([expr]) Return a string that indicates the current mode. s Select by character S Select by line CTRL-S Select blockwise + vs Visual by character using |v_CTRL-O| from + Select mode + Vs Visual by line using |v_CTRL-O| from Select mode + CTRL-Vs Visual blockwise using |v_CTRL-O| from Select mode i Insert ic Insert mode completion |compl-generic| ix Insert mode |i_CTRL-X| completion diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 55a912b417..7b2320effa 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -524,6 +524,8 @@ EXTERN pos_T VIsual; EXTERN int VIsual_active INIT(= false); /// Whether Select mode is active. EXTERN int VIsual_select INIT(= false); +/// Restart Select mode when next cmd finished +EXTERN int restart_VIsual_select INIT(= 0); /// Whether to restart the selection after a Select-mode mapping or menu. EXTERN int VIsual_reselect; /// Type of Visual mode. diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 4213e6f946..9185062f94 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -92,8 +92,6 @@ static linenr_T resel_VIsual_line_count; /* number of lines */ static colnr_T resel_VIsual_vcol; /* nr of cols or end col */ static int VIsual_mode_orig = NUL; /* saved Visual mode */ -static int restart_VIsual_select = 0; - #ifdef INCLUDE_GENERATED_DECLARATIONS # include "normal.c.generated.h" diff --git a/src/nvim/state.c b/src/nvim/state.c index 437cb0db47..02d63d8ab1 100644 --- a/src/nvim/state.c +++ b/src/nvim/state.c @@ -144,6 +144,9 @@ char *get_mode(void) buf[0] = (char)(VIsual_mode + 's' - 'v'); } else { buf[0] = (char)VIsual_mode; + if (restart_VIsual_select) { + buf[1] = 's'; + } } } else if (State == HITRETURN || State == ASKMORE || State == SETWSIZE || State == CONFIRM) { diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index 224ca257ab..7c00b479a3 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -534,6 +534,7 @@ func Test_mode() set complete=. inoremap =Save_mode() + xnoremap call Save_mode() normal! 3G exe "normal i\\" @@ -645,6 +646,14 @@ func Test_mode() call assert_equal("\", mode(1)) call feedkeys("\", 'xt') + " v_CTRL-O + exe "normal gh\\\" + call assert_equal("v-vs", g:current_modes) + exe "normal gH\\\" + call assert_equal("V-Vs", g:current_modes) + exe "normal g\\\\" + call assert_equal("\-\s", g:current_modes) + call feedkeys(":echo \=Save_mode()\\", 'xt') call assert_equal('c-c', g:current_modes) call feedkeys("gQecho \=Save_mode()\\vi\", 'xt') @@ -653,6 +662,7 @@ func Test_mode() bwipe! iunmap + xunmap set complete& endfunc