]> granicus.if.org Git - vim/commitdiff
patch 8.2.2916: operators are not fully tested v8.2.2916
authorYegappan Lakshmanan <yegappan@yahoo.com>
Mon, 31 May 2021 17:23:01 +0000 (19:23 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 31 May 2021 17:23:01 +0000 (19:23 +0200)
Problem:    Operators are not fully tested.
Solution:   Add a few more tests. (Yegappan Lakshmanan, closes #8290)

src/ops.c
src/testdir/test_netbeans.vim
src/testdir/test_normal.vim
src/testdir/test_visual.vim
src/version.c

index e4590a1e75720d31fbe50ddddd77968dc29dfd2e..87fb2a05b49195d131c5092b79eff5731cbfd0ac 100644 (file)
--- a/src/ops.c
+++ b/src/ops.c
@@ -2383,9 +2383,10 @@ op_addsub(
 #ifdef FEAT_NETBEANS_INTG
            if (netbeans_active() && one_change)
            {
-               char_u *ptr = ml_get_buf(curbuf, pos.lnum, FALSE);
+               char_u *ptr;
 
                netbeans_removed(curbuf, pos.lnum, pos.col, (long)length);
+               ptr = ml_get_buf(curbuf, pos.lnum, FALSE);
                netbeans_inserted(curbuf, pos.lnum, pos.col,
                                                &ptr[pos.col], length);
            }
index d792ab97c608450bf4e0334f651d199106b5114a..8dff32d0b7a5f294c06222f10ce50e30dd1aff3a 100644 (file)
@@ -367,6 +367,46 @@ func Nb_basic(port)
   call assert_match('2:insert=\d\+ 26 "\t"', l[-1])
   let g:last += 18
 
+  " Test for changing case of multiple lines using ~
+  normal ggVG~
+  call WaitFor('len(ReadXnetbeans()) >= (g:last + 6)')
+  let l = ReadXnetbeans()
+  call assert_match('2:remove=\d\+ 0 8', l[-6])
+  call assert_match('2:insert=\d\+ 0 "FOO BAR2"', l[-5])
+  call assert_match('2:remove=\d\+ 9 8', l[-4])
+  call assert_match('2:insert=\d\+ 9 "BLUE SKy"', l[-3])
+  call assert_match('2:remove=\d\+ 18 9', l[-2])
+  call assert_match('2:insert=\d\+ 18 "\tFOO BAR3"', l[-1])
+  let g:last += 6
+
+  " Test for changing case of a visual block using ~
+  exe "normal ggw\<C-V>$~"
+  call WaitFor('len(ReadXnetbeans()) >= (g:last + 2)')
+  let l = ReadXnetbeans()
+  call assert_match('2:remove=\d\+ 4 4', l[-2])
+  call assert_match('2:insert=\d\+ 4 "bar2"', l[-1])
+  let g:last += 2
+
+  " Increment a number using <C-A> in visual mode
+  exe "normal! gg$v6\<C-A>"
+  call WaitFor('len(ReadXnetbeans()) >= (g:last + 6)')
+  let l = ReadXnetbeans()
+  call assert_match('2:remove=\d\+ 0 9', l[-4])
+  call assert_match('2:insert=\d\+ 0 "FOO bar8"', l[-3])
+  call assert_match('2:remove=\d\+ 7 1', l[-2])
+  call assert_match('2:insert=\d\+ 7 "8"', l[-1])
+  let g:last += 6
+
+  " Decrement a number using <C-X> in visual mode
+  exe "normal! gg$v3\<C-X>"
+  call WaitFor('len(ReadXnetbeans()) >= (g:last + 6)')
+  let l = ReadXnetbeans()
+  call assert_match('2:remove=\d\+ 0 9', l[-4])
+  call assert_match('2:insert=\d\+ 0 "FOO bar5"', l[-3])
+  call assert_match('2:remove=\d\+ 7 1', l[-2])
+  call assert_match('2:insert=\d\+ 7 "5"', l[-1])
+  let g:last += 6
+
   " stopDocumentListen test
   call appendbufline(cmdbufnr, '$', 'stopDocumentListen_Test')
   call WaitFor('len(ReadXnetbeans()) >= (g:last + 3)')
index 48cc46e0749cf3506cebd16ec02f563fb7eb1487..63acebc6e1a16858f725d6fb3d364694cf2bd61f 100644 (file)
@@ -3377,4 +3377,34 @@ func Test_normal_shift_rightleft()
   bw!
 endfunc
 
+" Some commands like yy, cc, dd, >>, << and !! accept a count after
+" typing the first letter of the command.
+func Test_normal_count_after_operator()
+  new
+  setlocal shiftwidth=4 tabstop=8 autoindent
+  call setline(1, ['one', 'two', 'three', 'four', 'five'])
+  let @a = ''
+  normal! j"ay4y
+  call assert_equal("two\nthree\nfour\nfive\n", @a)
+  normal! 3G>2>
+  call assert_equal(['one', 'two', '    three', '    four', 'five'],
+        \ getline(1, '$'))
+  exe "normal! 3G0c2cred\nblue"
+  call assert_equal(['one', 'two', '    red', '    blue', 'five'],
+        \ getline(1, '$'))
+  exe "normal! gg<8<"
+  call assert_equal(['one', 'two', 'red', 'blue', 'five'],
+        \ getline(1, '$'))
+  exe "normal! ggd3d"
+  call assert_equal(['blue', 'five'], getline(1, '$'))
+  call setline(1, range(1, 4))
+  call feedkeys("gg!3!\<C-B>\"\<CR>", 'xt')
+  call assert_equal('".,.+2!', @:)
+  call feedkeys("gg!1!\<C-B>\"\<CR>", 'xt')
+  call assert_equal('".!', @:)
+  call feedkeys("gg!9!\<C-B>\"\<CR>", 'xt')
+  call assert_equal('".,$!', @:)
+  bw!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 2b3b2139ee0cd6d9a7e3420d52c43b5168c5d12c..1b3661c228996a830fa14014eddc53a529d67a5e 100644 (file)
@@ -818,7 +818,99 @@ func Test_visual_block_mode()
   exe "normal ld\<C-V>j"
   call assert_equal(['13', '46', '789'], getline(1, '$'))
 
+  " Test from ':help v_b_I_example'
+  %d _
+  setlocal tabstop=8 shiftwidth=4
+  let lines =<< trim END
+    abcdefghijklmnopqrstuvwxyz
+    abc                defghijklmnopqrstuvwxyz
+    abcdef  ghi                jklmnopqrstuvwxyz
+    abcdefghijklmnopqrstuvwxyz
+  END
+  call setline(1, lines)
+  exe "normal ggfo\<C-V>3jISTRING"
+  let expected =<< trim END
+    abcdefghijklmnSTRINGopqrstuvwxyz
+    abc              STRING  defghijklmnopqrstuvwxyz
+    abcdef  ghi   STRING       jklmnopqrstuvwxyz
+    abcdefghijklmnSTRINGopqrstuvwxyz
+  END
+  call assert_equal(expected, getline(1, '$'))
+
+  " Test from ':help v_b_A_example'
+  %d _
+  let lines =<< trim END
+    abcdefghijklmnopqrstuvwxyz
+    abc                defghijklmnopqrstuvwxyz
+    abcdef  ghi                jklmnopqrstuvwxyz
+    abcdefghijklmnopqrstuvwxyz
+  END
+  call setline(1, lines)
+  exe "normal ggfo\<C-V>3j$ASTRING"
+  let expected =<< trim END
+    abcdefghijklmnopqrstuvwxyzSTRING
+    abc                defghijklmnopqrstuvwxyzSTRING
+    abcdef  ghi                jklmnopqrstuvwxyzSTRING
+    abcdefghijklmnopqrstuvwxyzSTRING
+  END
+  call assert_equal(expected, getline(1, '$'))
+
+  " Test from ':help v_b_<_example'
+  %d _
+  let lines =<< trim END
+    abcdefghijklmnopqrstuvwxyz
+    abc                defghijklmnopqrstuvwxyz
+    abcdef  ghi                jklmnopqrstuvwxyz
+    abcdefghijklmnopqrstuvwxyz
+  END
+  call setline(1, lines)
+  exe "normal ggfo\<C-V>3j3l<.."
+  let expected =<< trim END
+    abcdefghijklmnopqrstuvwxyz
+    abc              defghijklmnopqrstuvwxyz
+    abcdef  ghi   jklmnopqrstuvwxyz
+    abcdefghijklmnopqrstuvwxyz
+  END
+  call assert_equal(expected, getline(1, '$'))
+
+  " Test from ':help v_b_>_example'
+  %d _
+  let lines =<< trim END
+    abcdefghijklmnopqrstuvwxyz
+    abc                defghijklmnopqrstuvwxyz
+    abcdef  ghi                jklmnopqrstuvwxyz
+    abcdefghijklmnopqrstuvwxyz
+  END
+  call setline(1, lines)
+  exe "normal ggfo\<C-V>3j>.."
+  let expected =<< trim END
+    abcdefghijklmn               opqrstuvwxyz
+    abc                            defghijklmnopqrstuvwxyz
+    abcdef  ghi                            jklmnopqrstuvwxyz
+    abcdefghijklmn               opqrstuvwxyz
+  END
+  call assert_equal(expected, getline(1, '$'))
+
+  " Test from ':help v_b_r_example'
+  %d _
+  let lines =<< trim END
+    abcdefghijklmnopqrstuvwxyz
+    abc                defghijklmnopqrstuvwxyz
+    abcdef  ghi                jklmnopqrstuvwxyz
+    abcdefghijklmnopqrstuvwxyz
+  END
+  call setline(1, lines)
+  exe "normal ggfo\<C-V>5l3jrX"
+  let expected =<< trim END
+    abcdefghijklmnXXXXXXuvwxyz
+    abc              XXXXXXhijklmnopqrstuvwxyz
+    abcdef  ghi   XXXXXX    jklmnopqrstuvwxyz
+    abcdefghijklmnXXXXXXuvwxyz
+  END
+  call assert_equal(expected, getline(1, '$'))
+
   bwipe!
+  set tabstop& shiftwidth&
 endfunc
 
 " Test block-insert using cursor keys for movement
index 858477852be23855d56c33a246ae0d60951a678b..87eb4843049492f9e762775be92717a52ab1d86f 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2916,
 /**/
     2915,
 /**/