updated for version 7.4b.020 v7.4b.020
authorBram Moolenaar <Bram@vim.org>
Fri, 9 Aug 2013 17:48:40 +0000 (19:48 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 9 Aug 2013 17:48:40 +0000 (19:48 +0200)
Problem:    "g~ap" changes first character of next paragraph. (Manuel Ortega)
Solution:   Avoid subtracting (0 - 1) from todo.  (Mike Williams)

src/ops.c
src/testdir/test82.in
src/testdir/test82.ok
src/version.c

index 3ee6e551602b0285254c0efc81dfbe393baefca2..3989802d38ee442a20163d6317fc06bfbeb4fd84 100644 (file)
--- a/src/ops.c
+++ b/src/ops.c
@@ -2429,8 +2429,13 @@ swapchars(op_type, pos, length)
     {
 # ifdef FEAT_MBYTE
        if (has_mbyte)
+       {
+           int len = (*mb_ptr2len)(ml_get_pos(pos));
+
            /* we're counting bytes, not characters */
-           todo -= (*mb_ptr2len)(ml_get_pos(pos)) - 1;
+           if (len > 0)
+               todo -= len - 1;
+       }
 # endif
        did_change |= swapchar(op_type, pos);
        if (inc(pos) == -1)    /* at end of file */
index 63a81e7898f003f904000850b9666410ece074aa..8503f5488fdec83d1663dda551b56f56b769d25b 100644 (file)
@@ -1,4 +1,5 @@
 Tests for case-insensitive UTF-8 comparisons (utf_strnicmp() in mbyte.c)
+Also test "g~ap".
 
 STARTTEST
 :so small.vim
@@ -88,6 +89,15 @@ ggdG
 :for n in range(0x80, 0xBF) | call EQ(printf('xYz\xc2\x%.2XUvW', n), printf('XyZ\xc2\x%.2XuVw', n)) | endfor
 :for n in range(0xC0, 0xFF) | call LT(printf('xYz\xc2\x%.2XUvW', n), printf('XyZ\xc2\x%.2XuVw', n)) | endfor
 :call append(0, printf('%d checks passed', b:passed))
+:"
+:" test that g~ap changes one paragraph only.
+:new
+iabcd
+
+defg\egg0g~ap:let lns = getline(1,3)
+:q!
+:call append(line('$'), lns)
+:"
 :wq! test.out
 ENDTEST
 
index fa65883466b83baccd23287a6f3ee00b16b40606..3f1866a0fbc1cb7b15a32adeae4c95257da5ee2b 100644 (file)
@@ -1,2 +1,5 @@
 3732 checks passed
 
+ABCD
+
+defg
index 5e4a5954372f0c8e77348e34c4fd0c04124137f5..3add57dd98894f4d2e1e2e98866e8f2d8e9abd75 100644 (file)
@@ -727,6 +727,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    20,
 /**/
     19,
 /**/