Skip to content

Commit 1253704

Browse files
committed
patch 8.1.1486: a listener change is merged even when it adds a line
Problem: A listener change is merged even when it adds a line. (Paul Jolly) Solution: Do not merge a change that adds or removes a line. (closes #4490)
1 parent 773a97c commit 1253704

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

src/change.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ check_recorded_changes(
186186
|| (prev_lnume >= lnum && xtra != 0))
187187
{
188188
if (li->li_next == NULL && lnum == prev_lnum
189+
&& xtra == 0
189190
&& col + 1 == (colnr_T)dict_get_number(
190191
li->li_tv.vval.v_dict, (char_u *)"col"))
191192
{

src/testdir/test_listener.vim

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ func Test_listening()
2828
set undolevels& " start new undo block
2929
call append(2, 'two two')
3030
undo
31+
call assert_equal([{'lnum': 3, 'end': 3, 'col': 1, 'added': 1}], s:list)
3132
redraw
32-
" the two changes get merged
33-
call assert_equal([{'lnum': 3, 'end': 4, 'col': 1, 'added': 0}], s:list)
33+
" the two changes are not merged
34+
call assert_equal([{'lnum': 3, 'end': 4, 'col': 1, 'added': -1}], s:list)
3435
1
3536

3637
" Two listeners, both get called. Also check column.
@@ -65,15 +66,16 @@ func Test_listening()
6566
call assert_equal([{'lnum': 3, 'end': 3, 'col': 1, 'added': 1},
6667
\ {'lnum': 1, 'end': 2, 'col': 1, 'added': 0}], s:list)
6768

68-
" an insert just above a previous change that was the last one gets merged
69+
" an insert just above a previous change that was the last one does not get
70+
" merged
6971
call setline(1, ['one one', 'two'])
7072
call listener_flush()
7173
let s:list = []
7274
call setline(2, 'something')
7375
call append(1, 'two two')
74-
call assert_equal([], s:list)
76+
call assert_equal([{'lnum': 2, 'end': 3, 'col': 1, 'added': 0}], s:list)
7577
call listener_flush()
76-
call assert_equal([{'lnum': 2, 'end': 3, 'col': 1, 'added': 1}], s:list)
78+
call assert_equal([{'lnum': 2, 'end': 2, 'col': 1, 'added': 1}], s:list)
7779

7880
" an insert above a previous change causes a flush
7981
call setline(1, ['one one', 'two'])
@@ -86,13 +88,13 @@ func Test_listening()
8688
call assert_equal([{'lnum': 1, 'end': 1, 'col': 1, 'added': 1}], s:list)
8789
call assert_equal('two two', s:text)
8890

89-
" a delete at a previous change that was the last one gets merged
91+
" a delete at a previous change that was the last one does not get merged
9092
call setline(1, ['one one', 'two'])
9193
call listener_flush()
9294
let s:list = []
9395
call setline(2, 'something')
9496
2del
95-
call assert_equal([], s:list)
97+
call assert_equal([{'lnum': 2, 'end': 3, 'col': 1, 'added': 0}], s:list)
9698
call listener_flush()
9799
call assert_equal([{'lnum': 2, 'end': 3, 'col': 1, 'added': -1}], s:list)
98100

src/version.c

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

768768
static int included_patches[] =
769769
{ /* Add new patch number below this line */
770+
/**/
771+
1486,
770772
/**/
771773
1485,
772774
/**/

0 commit comments

Comments
 (0)