]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.3236: mode() does not indicate using CTRL-O in Select mode v8.2.3236
authorzeertzjq <zeertzjq@outlook.com>
Wed, 28 Jul 2021 14:51:53 +0000 (16:51 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 28 Jul 2021 14:51:53 +0000 (16:51 +0200)
Problem:    mode() does not indicate using CTRL-O in Select mode.
Solution:   Use "vs" and similar. (closes #8640)

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

index d5f5e8de5ebc1397a2b71ae5c9a23d3a2ded0405..d99c398a72156817a431f92860755b210e6ac5ab 100644 (file)
@@ -7978,6 +7978,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
index 529901437a75484e5cafb25c2f929a5c82990703..ebf236b0003360014ed2cb36ad4c21118505c5b4 100644 (file)
@@ -882,6 +882,8 @@ EXTERN int  VIsual_active INIT(= FALSE);
                                // whether Visual mode is active
 EXTERN int     VIsual_select INIT(= FALSE);
                                // whether Select mode is active
+EXTERN int     restart_VIsual_select INIT(= 0);
+                               // restart Select mode when next cmd finished
 EXTERN int     VIsual_reselect;
                                // whether to restart the selection after a
                                // Select mode mapping or menu
index 7d7f022f1e4592c5c0b65998b25b885712fa84c8..9708502cad451e77a0e0955780ec21147486e3cd 100644 (file)
@@ -652,7 +652,11 @@ f_mode(typval_T *argvars, typval_T *rettv)
        if (VIsual_select)
            buf[0] = VIsual_mode + 's' - 'v';
        else
+       {
            buf[0] = VIsual_mode;
+           if (restart_VIsual_select)
+               buf[1] = 's';
+       }
     }
     else if (State == HITRETURN || State == ASKMORE || State == SETWSIZE
                || State == CONFIRM)
index 74c76b2d205be8020a11b76f78979e061bc3c92c..0e1e11801c7e420b71df934e8e55b486e5c77fdb 100644 (file)
@@ -15,7 +15,6 @@
 #include "vim.h"
 
 static int     VIsual_mode_orig = NUL;         // saved Visual mode
-static int     restart_VIsual_select = 0;
 
 #ifdef FEAT_EVAL
 static void    set_vcount_ca(cmdarg_T *cap, int *set_prevcount);
index 6f2797c497ec11c0cc3d8ca061432a3f991fbb29..de2db41f249fd868b6dfcc19555b653ec5dea8f3 100644 (file)
@@ -746,6 +746,7 @@ func Test_mode()
   set complete=.
 
   inoremap <F2> <C-R>=Save_mode()<CR>
+  xnoremap <F2> <Cmd>call Save_mode()<CR>
 
   normal! 3G
   exe "normal i\<F2>\<Esc>"
@@ -857,6 +858,14 @@ func Test_mode()
   call assert_equal("\<C-S>", mode(1))
   call feedkeys("\<Esc>", 'xt')
 
+  " v_CTRL-O
+  exe "normal gh\<C-O>\<F2>\<Esc>"
+  call assert_equal("v-vs", g:current_modes)
+  exe "normal gH\<C-O>\<F2>\<Esc>"
+  call assert_equal("V-Vs", g:current_modes)
+  exe "normal g\<C-H>\<C-O>\<F2>\<Esc>"
+  call assert_equal("\<C-V>-\<C-V>s", g:current_modes)
+
   call feedkeys(":echo \<C-R>=Save_mode()\<C-U>\<CR>", 'xt')
   call assert_equal('c-c', g:current_modes)
   call feedkeys("gQecho \<C-R>=Save_mode()\<CR>\<CR>vi\<CR>", 'xt')
@@ -867,6 +876,7 @@ func Test_mode()
 
   bwipe!
   iunmap <F2>
+  xunmap <F2>
   set complete&
 endfunc
 
index ea232c37ba1d054453185503b51fb99658fd56f3..ed3d516e1be65374d80c8d5350144676168dcd96 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3236,
 /**/
     3235,
 /**/