]> granicus.if.org Git - vim/commitdiff
patch 8.1.0290: "cit" on an empty HTML tag changes the whole tag v8.1.0290
authorBram Moolenaar <Bram@vim.org>
Thu, 16 Aug 2018 19:37:50 +0000 (21:37 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 16 Aug 2018 19:37:50 +0000 (21:37 +0200)
Problem:    "cit" on an empty HTML tag changes the whole tag.
Solution:   Only adjust the area in Visual mode. (Andy Massimino,
            closes #3332)

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

index 66ae6471854d495d8bede24216285dd05708f58a..a12a1d33c545a5af7da8f159fc39ed836aea4657 100644 (file)
@@ -4106,9 +4106,10 @@ again:
            }
        curwin->w_cursor = end_pos;
 
-       /* If we now have the same text as before reset "do_include" and try
-        * again. */
-       if (EQUAL_POS(start_pos, old_start) && EQUAL_POS(end_pos, old_end))
+       // If we are in Visual mode and now have the same text as before set
+       // "do_include" and try again.
+       if (VIsual_active && EQUAL_POS(start_pos, old_start)
+                                               && EQUAL_POS(end_pos, old_end))
        {
            do_include = TRUE;
            curwin->w_cursor = old_start;
index f02619fc09ded28c80434295b4c8f1743a2d07e9..6a2f5044cc35c8a799c580a051cbda0ea2d8470f 100644 (file)
@@ -121,6 +121,23 @@ func Test_string_html_objects()
   enew!
 endfunc
 
+func Test_empty_html_tag()
+  new
+  call setline(1, '<div></div>')
+  normal 0citxxx
+  call assert_equal('<div>xxx</div>', getline(1))
+
+  call setline(1, '<div></div>')
+  normal 0f<cityyy
+  call assert_equal('<div>yyy</div>', getline(1))
+
+  call setline(1, '<div></div>')
+  normal 0f<vitsaaa
+  call assert_equal('aaa', getline(1))
+
+  bwipe!
+endfunc
+
 " Tests for match() and matchstr()
 func Test_match()
   call assert_equal("b", matchstr("abcd", ".", 0, 2))
index 66e79d88c15d22227a456bdb18ba63d37e84b8b9..279908e04383f77bb389a7e93cfd6c2a49673f02 100644 (file)
@@ -794,6 +794,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    290,
 /**/
     289,
 /**/