Skip to content

Commit 0fd1cb1

Browse files
kuuotechrisbra
authored andcommitted
patch 9.1.0683: mode() returns wrong value with <Cmd> mapping
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>
1 parent 3840d2f commit 0fd1cb1

3 files changed

Lines changed: 17 additions & 11 deletions

File tree

src/misc1.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -678,17 +678,6 @@ get_mode(char_u *buf)
678678
buf[i++] = 't';
679679
}
680680
#endif
681-
else if (VIsual_active)
682-
{
683-
if (VIsual_select)
684-
buf[i++] = VIsual_mode + 's' - 'v';
685-
else
686-
{
687-
buf[i++] = VIsual_mode;
688-
if (restart_VIsual_select)
689-
buf[i++] = 's';
690-
}
691-
}
692681
else if (State == MODE_HITRETURN || State == MODE_ASKMORE
693682
|| State == MODE_SETWSIZE
694683
|| State == MODE_CONFIRM)
@@ -731,6 +720,17 @@ get_mode(char_u *buf)
731720
if ((State & MODE_CMDLINE) && cmdline_overstrike())
732721
buf[i++] = 'r';
733722
}
723+
else if (VIsual_active)
724+
{
725+
if (VIsual_select)
726+
buf[i++] = VIsual_mode + 's' - 'v';
727+
else
728+
{
729+
buf[i++] = VIsual_mode;
730+
if (restart_VIsual_select)
731+
buf[i++] = 's';
732+
}
733+
}
734734
else
735735
{
736736
buf[i++] = 'n';

src/testdir/test_functions.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,10 @@ func Test_mode()
923923
call feedkeys("gQ\<Insert>\<F2>vi\<CR>", 'xt')
924924
call assert_equal("c-cvr", g:current_modes)
925925

926+
" Commandline mode in Visual mode should return "c-c", never "v-v".
927+
call feedkeys("v\<Cmd>call input('')\<CR>\<F2>\<CR>\<Esc>", 'xt')
928+
call assert_equal("c-c", g:current_modes)
929+
926930
" Executing commands in Vim Ex mode should return "cv", never "cvr",
927931
" as Cmdline editing has already ended.
928932
call feedkeys("gQcall Save_mode()\<CR>vi\<CR>", 'xt')

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
683,
707709
/**/
708710
682,
709711
/**/

0 commit comments

Comments
 (0)