patch 9.1.0012: regression with empty inner blocks introduced

Commit: 
https://github.com/vim/vim/commit/3779516988f14f2070d827514c79383334a0946b
Author: Maxim Kim <[email protected]>
Date:   Fri Jan 5 17:52:49 2024 +0100

    patch 9.1.0012: regression with empty inner blocks introduced
    
    Problem:  regression with empty inner blocks introduced
              (after v9.1.0007)
    Solution: Set correct cursor position, Check for visual mode
              being active (Maxim Kim)
    
    relates: #13514
    closes: #13819
    
    Signed-off-by: Maxim Kim <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/testdir/test_textobjects.vim b/src/testdir/test_textobjects.vim
index 89e741c71..d5e772db5 100644
--- a/src/testdir/test_textobjects.vim
+++ b/src/testdir/test_textobjects.vim
@@ -643,7 +643,7 @@ endfunc
 
 func Test_inner_block_empty_paren()
   new
-  call setline(1, ["(text)()", "", "(text)(", ")", "", "()()"])
+  call setline(1, ["(text)()", "", "(text)(", ")", "", "()()", "", "text()"])
 
   " Example 1
   call cursor(1, 1)
@@ -665,12 +665,18 @@ func Test_inner_block_empty_paren()
   call assert_beeps('call feedkeys("0f(viby", "xt")')
   call assert_equal(3, getpos('.')[2])
   call assert_equal('(', @")
+
+  " Change empty inner block
+  call cursor(8, 1)
+  call feedkeys("0cibtext", "xt")
+  call assert_equal("text(text)", getline('.'))
+
   bwipe!
 endfunc
 
 func Test_inner_block_empty_bracket()
   new
-  call setline(1, ["[text][]", "", "[text][", "]", "", "[][]"])
+  call setline(1, ["[text][]", "", "[text][", "]", "", "[][]", "", "text[]"])
 
   " Example 1
   call cursor(1, 1)
@@ -692,12 +698,18 @@ func Test_inner_block_empty_bracket()
   call assert_beeps('call feedkeys("0f[viby", "xt")')
   call assert_equal(3, getpos('.')[2])
   call assert_equal('[', @")
+
+  " Change empty inner block
+  call cursor(8, 1)
+  call feedkeys("0ci[text", "xt")
+  call assert_equal("text[text]", getline('.'))
+
   bwipe!
 endfunc
 
 func Test_inner_block_empty_brace()
   new
-  call setline(1, ["{text}{}", "", "{text}{", "}", "", "{}{}"])
+  call setline(1, ["{text}{}", "", "{text}{", "}", "", "{}{}", "", "text{}"])
 
   " Example 1
   call cursor(1, 1)
@@ -719,6 +731,12 @@ func Test_inner_block_empty_brace()
   call assert_beeps('call feedkeys("0f{viby", "xt")')
   call assert_equal(3, getpos('.')[2])
   call assert_equal('{', @")
+
+  " Change empty inner block
+  call cursor(8, 1)
+  call feedkeys("0ciBtext", "xt")
+  call assert_equal("text{text}", getline('.'))
+
   bwipe!
 endfunc
 
diff --git a/src/textobject.c b/src/textobject.c
index af94d06bc..015b33bbf 100644
--- a/src/textobject.c
+++ b/src/textobject.c
@@ -1131,10 +1131,15 @@ current_block(
                break;
        }
 
-       if (EQUAL_POS(start_pos, *end_pos))
-           // empty block like this: ()
-           // there is no inner block to select, abort
+       /*
+        * In Visual mode, when resulting area is empty
+        * i.e. there is no inner block to select, abort.
+        */
+       if (EQUAL_POS(start_pos, *end_pos) && VIsual_active)
+       {
+           curwin->w_cursor = old_pos;
            return FAIL;
+       }
 
        /*
         * In Visual mode, when the resulting area is not bigger than what we
diff --git a/src/version.c b/src/version.c
index d45181d9d..35865d696 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    12,
 /**/
     11,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/E1rLnYC-00ET12-5Q%40256bit.org.

Raspunde prin e-mail lui