Skip to content

Commit bebd20b

Browse files
committed
updated for version 7.4b.020
Problem: "g~ap" changes first character of next paragraph. (Manuel Ortega) Solution: Avoid subtracting (0 - 1) from todo. (Mike Williams)
1 parent df4a817 commit bebd20b

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

src/ops.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2429,8 +2429,13 @@ swapchars(op_type, pos, length)
24292429
{
24302430
# ifdef FEAT_MBYTE
24312431
if (has_mbyte)
2432+
{
2433+
int len = (*mb_ptr2len)(ml_get_pos(pos));
2434+
24322435
/* we're counting bytes, not characters */
2433-
todo -= (*mb_ptr2len)(ml_get_pos(pos)) - 1;
2436+
if (len > 0)
2437+
todo -= len - 1;
2438+
}
24342439
# endif
24352440
did_change |= swapchar(op_type, pos);
24362441
if (inc(pos) == -1) /* at end of file */

src/testdir/test82.in

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Tests for case-insensitive UTF-8 comparisons (utf_strnicmp() in mbyte.c)
2+
Also test "g~ap".
23

34
STARTTEST
45
:so small.vim
@@ -88,6 +89,15 @@ ggdG
8889
:for n in range(0x80, 0xBF) | call EQ(printf('xYz\xc2\x%.2XUvW', n), printf('XyZ\xc2\x%.2XuVw', n)) | endfor
8990
:for n in range(0xC0, 0xFF) | call LT(printf('xYz\xc2\x%.2XUvW', n), printf('XyZ\xc2\x%.2XuVw', n)) | endfor
9091
:call append(0, printf('%d checks passed', b:passed))
92+
:"
93+
:" test that g~ap changes one paragraph only.
94+
:new
95+
iabcd
96+
97+
defggg0g~ap:let lns = getline(1,3)
98+
:q!
99+
:call append(line('$'), lns)
100+
:"
91101
:wq! test.out
92102
ENDTEST
93103

src/testdir/test82.ok

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
3732 checks passed
22

3+
ABCD
4+
5+
defg

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,8 @@ static char *(features[]) =
727727

728728
static int included_patches[] =
729729
{ /* Add new patch number below this line */
730+
/**/
731+
20,
730732
/**/
731733
19,
732734
/**/

0 commit comments

Comments
 (0)