]> granicus.if.org Git - vim/commitdiff
patch 8.2.5012: cannot select one character inside () v8.2.5012
authorLemonBoy <thatlemon@gmail.com>
Tue, 24 May 2022 10:49:31 +0000 (11:49 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 24 May 2022 10:49:31 +0000 (11:49 +0100)
Problem:    Cannot select one character inside ().
Solution:   Do not try to extend the area if it is empty. (closes #10472,
            closes #6616)

src/testdir/test_textobjects.vim
src/textobject.c
src/version.c

index 34894d068a2a413c6ef3a9018471578fa2a46b1d..b605d76f2fe0a54c206442081b6c344f8cf594c1 100644 (file)
@@ -41,6 +41,24 @@ func Test_inner_block_with_cpo_M_right_backslash()
   call CpoM('(red (blue\) green)', 1, ['red (blue\) green', 'blue\', 'red (blue\) green'])
 endfunc
 
+func Test_inner_block_single_char()
+  new
+  call setline(1, "(a)")
+
+  set selection=inclusive
+  let @" = ''
+  call assert_nobeep('norm! 0faviby')
+  call assert_equal('a', @")
+
+  set selection=exclusive
+  let @" = ''
+  call assert_nobeep('norm! 0faviby')
+  call assert_equal('a', @")
+
+  set selection&
+  bwipe!
+endfunc
+
 func Test_quote_selection_selection_exclusive()
   new
   call setline(1, "a 'bcde' f")
@@ -49,11 +67,11 @@ func Test_quote_selection_selection_exclusive()
   exe "norm! fdvhi'y"
   call assert_equal('bcde', @")
 
-  let @"='dummy'
+  let @" = 'dummy'
   exe "norm! $gevi'y"
   call assert_equal('bcde', @")
 
-  let @"='dummy'
+  let @" = 'dummy'
   exe "norm! 0fbhvi'y"
   call assert_equal('bcde', @")
 
index edaa64c51cc3ad34b0e5ac110831452c0312a418..9a8a91626042cd5d20478beff8916596220e10d1 100644 (file)
@@ -1133,8 +1133,10 @@ current_block(
        /*
         * In Visual mode, when the resulting area is not bigger than what we
         * started with, extend it to the next block, and then exclude again.
+        * Don't try to expand the area if the area is empty.
         */
        if (!LT_POS(start_pos, old_start) && !LT_POS(old_end, curwin->w_cursor)
+               && !EQUAL_POS(start_pos, curwin->w_cursor)
                && VIsual_active)
        {
            curwin->w_cursor = old_start;
index 5ea047ac37944821cf4eb3017f78bdc3c91691e7..dea37d6cdd0d569b20f4fb484b74b077a1b995ed 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    5012,
 /**/
     5011,
 /**/