]> granicus.if.org Git - vim/commitdiff
patch 8.1.1486: a listener change is merged even when it adds a line v8.1.1486
authorBram Moolenaar <Bram@vim.org>
Thu, 6 Jun 2019 20:50:35 +0000 (22:50 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 6 Jun 2019 20:50:35 +0000 (22:50 +0200)
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)

src/change.c
src/testdir/test_listener.vim
src/version.c

index 07985ee62ab1eca08d29f11039f014a07d7010fb..fcaa5708a98e59eed29909889c08864ca3ef1227 100644 (file)
@@ -186,6 +186,7 @@ check_recorded_changes(
                    || (prev_lnume >= lnum && xtra != 0))
            {
                if (li->li_next == NULL && lnum == prev_lnum
+                       && xtra == 0
                        && col + 1 == (colnr_T)dict_get_number(
                                      li->li_tv.vval.v_dict, (char_u *)"col"))
                {
index 16c4c0022c7adca4d319778614a7168b4b0b7f67..a318d527aef6a14660f51bd13de85f8c3a3caab8 100644 (file)
@@ -28,9 +28,10 @@ func Test_listening()
   set undolevels&  " start new undo block
   call append(2, 'two two')
   undo
+  call assert_equal([{'lnum': 3, 'end': 3, 'col': 1, 'added': 1}], s:list)
   redraw
-  " the two changes get merged
-  call assert_equal([{'lnum': 3, 'end': 4, 'col': 1, 'added': 0}], s:list)
+  " the two changes are not merged
+  call assert_equal([{'lnum': 3, 'end': 4, 'col': 1, 'added': -1}], s:list)
   1
 
   " Two listeners, both get called.  Also check column.
@@ -65,15 +66,16 @@ func Test_listening()
   call assert_equal([{'lnum': 3, 'end': 3, 'col': 1, 'added': 1},
        \ {'lnum': 1, 'end': 2, 'col': 1, 'added': 0}], s:list)
 
-  " an insert just above a previous change that was the last one gets merged
+  " an insert just above a previous change that was the last one does not get
+  " merged
   call setline(1, ['one one', 'two'])
   call listener_flush()
   let s:list = []
   call setline(2, 'something')
   call append(1, 'two two')
-  call assert_equal([], s:list)
+  call assert_equal([{'lnum': 2, 'end': 3, 'col': 1, 'added': 0}], s:list)
   call listener_flush()
-  call assert_equal([{'lnum': 2, 'end': 3, 'col': 1, 'added': 1}], s:list)
+  call assert_equal([{'lnum': 2, 'end': 2, 'col': 1, 'added': 1}], s:list)
 
   " an insert above a previous change causes a flush
   call setline(1, ['one one', 'two'])
@@ -86,13 +88,13 @@ func Test_listening()
   call assert_equal([{'lnum': 1, 'end': 1, 'col': 1, 'added': 1}], s:list)
   call assert_equal('two two', s:text)
 
-  " a delete at a previous change that was the last one gets merged
+  " a delete at a previous change that was the last one does not get merged
   call setline(1, ['one one', 'two'])
   call listener_flush()
   let s:list = []
   call setline(2, 'something')
   2del
-  call assert_equal([], s:list)
+  call assert_equal([{'lnum': 2, 'end': 3, 'col': 1, 'added': 0}], s:list)
   call listener_flush()
   call assert_equal([{'lnum': 2, 'end': 3, 'col': 1, 'added': -1}], s:list)
 
index 4c44f2e3cb80db86759e88001ea560c093301939..bfda6187331b0ab8c010a8885e327cdee76b0147 100644 (file)
@@ -767,6 +767,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1486,
 /**/
     1485,
 /**/