]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0683: mode() returns wrong value with <Cmd> mapping v9.1.0683
authorkuuote <znmxodq1@gmail.com>
Tue, 20 Aug 2024 17:53:17 +0000 (19:53 +0200)
committerChristian Brabandt <cb@256bit.org>
Tue, 20 Aug 2024 17:53:17 +0000 (19:53 +0200)
Problem:  mode() returns wrong value with <Cmd> mapping
Solution: Change decision priority of VIsual_active and move
          visual mode a bit further down (kuuote)

closes: #15533

Signed-off-by: kuuote <znmxodq1@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/misc1.c
src/testdir/test_functions.vim
src/version.c

index 8348488862412a5eada4f608c6d52e1f9ce93576..0898efb33f6e955845210ecd834ab85328a05476 100644 (file)
@@ -678,17 +678,6 @@ get_mode(char_u *buf)
        buf[i++] = 't';
     }
 #endif
-    else if (VIsual_active)
-    {
-       if (VIsual_select)
-           buf[i++] = VIsual_mode + 's' - 'v';
-       else
-       {
-           buf[i++] = VIsual_mode;
-           if (restart_VIsual_select)
-               buf[i++] = 's';
-       }
-    }
     else if (State == MODE_HITRETURN || State == MODE_ASKMORE
                                                      || State == MODE_SETWSIZE
                || State == MODE_CONFIRM)
@@ -731,6 +720,17 @@ get_mode(char_u *buf)
        if ((State & MODE_CMDLINE) && cmdline_overstrike())
            buf[i++] = 'r';
     }
+    else if (VIsual_active)
+    {
+       if (VIsual_select)
+           buf[i++] = VIsual_mode + 's' - 'v';
+       else
+       {
+           buf[i++] = VIsual_mode;
+           if (restart_VIsual_select)
+               buf[i++] = 's';
+       }
+    }
     else
     {
        buf[i++] = 'n';
index 8e973f6c9ec7accf95d47fa736b1b234c36804db..1021d050901c0f68f0d484c019dfc30c86c6495c 100644 (file)
@@ -923,6 +923,10 @@ func Test_mode()
   call feedkeys("gQ\<Insert>\<F2>vi\<CR>", 'xt')
   call assert_equal("c-cvr", g:current_modes)
 
+  " Commandline mode in Visual mode should return "c-c", never "v-v".
+  call feedkeys("v\<Cmd>call input('')\<CR>\<F2>\<CR>\<Esc>", 'xt')
+  call assert_equal("c-c", g:current_modes)
+
   " Executing commands in Vim Ex mode should return "cv", never "cvr",
   " as Cmdline editing has already ended.
   call feedkeys("gQcall Save_mode()\<CR>vi\<CR>", 'xt')
index c4472cf609b80eacd0a7f9aa83b740955f45befb..8d26a0dc04591d5a59ef2124188c3e99dda59a23 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    683,
 /**/
     682,
 /**/