]> granicus.if.org Git - vim/commitdiff
patch 8.1.1389: changes are not flushed when end and start overlap v8.1.1389
authorBram Moolenaar <Bram@vim.org>
Fri, 24 May 2019 19:39:27 +0000 (21:39 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 24 May 2019 19:39:27 +0000 (21:39 +0200)
Problem:    Changes are not flushed when end and start overlap. (Paul Jolly)
Solution:   When end of a previous changes overlaps with start of a new
            change, first flush listeners.

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

index 8f0cacb4509f4290ebade6450083a2f8532264c4..0873dd3d898e2e8961fece2c19ef7c0a0aa81d1c 100644 (file)
@@ -172,16 +172,20 @@ check_recorded_changes(
     if (buf->b_recorded_changes != NULL && xtra != 0)
     {
        listitem_T *li;
-       linenr_T    nr;
+       linenr_T    prev_lnum;
+       linenr_T    prev_lnume;
 
        for (li = buf->b_recorded_changes->lv_first; li != NULL;
                                                              li = li->li_next)
        {
-           nr = (linenr_T)dict_get_number(
+           prev_lnum = (linenr_T)dict_get_number(
                                      li->li_tv.vval.v_dict, (char_u *)"lnum");
-           if (nr >= lnum || nr > lnume)
+           prev_lnume = (linenr_T)dict_get_number(
+                                      li->li_tv.vval.v_dict, (char_u *)"end");
+           if (prev_lnum >= lnum || prev_lnum > lnume
+                   || (prev_lnume >= lnum && xtra != 0))
            {
-               if (li->li_next == NULL && lnum == nr
+               if (li->li_next == NULL && lnum == prev_lnum
                        && col + 1 == (colnr_T)dict_get_number(
                                      li->li_tv.vval.v_dict, (char_u *)"col"))
                {
@@ -195,8 +199,8 @@ check_recorded_changes(
                                                          (char_u *)"end", -1);
                        if (di != NULL)
                        {
-                           nr = tv_get_number(&di->di_tv);
-                           if (lnume > nr)
+                           prev_lnum = tv_get_number(&di->di_tv);
+                           if (lnume > prev_lnum)
                                di->di_tv.vval.v_number = lnume;
                        }
                        di = dict_find(li->li_tv.vval.v_dict,
index 66c3d514398fafdf9c968eb3f1de247f69f3e13f..16c4c0022c7adca4d319778614a7168b4b0b7f67 100644 (file)
@@ -187,6 +187,17 @@ func Test_listener_args()
        \ {'lnum': 4, 'end': 5, 'col': 1, 'added': -1},
        \ {'lnum': 6, 'end': 6, 'col': 1, 'added': 1}], s:list)
 
+  " split a line then insert one, should get two disconnected change lists
+  call setline(1, 'split here')
+  call listener_flush()
+  let s:list = []
+  exe "normal 1ggwi\<CR>\<Esc>"
+  1
+  normal o
+  call assert_equal([{'lnum': 1, 'end': 2, 'col': 7, 'added': 1}], s:list)
+  call listener_flush()
+  call assert_equal([{'lnum': 2, 'end': 2, 'col': 1, 'added': 1}], s:list)
+
   call listener_remove(id)
   bwipe!
 endfunc
index 81b7486bd009931ac0677afe01ad2c6fa1a47393..03ad4bcdf0932c42265508680c2803c1cd017b1f 100644 (file)
@@ -767,6 +767,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1389,
 /**/
     1388,
 /**/