]> granicus.if.org Git - vim/commitdiff
patch 8.1.0458: ml_get error and crash when using "do" v8.1.0458
authorBram Moolenaar <Bram@vim.org>
Sun, 7 Oct 2018 15:46:42 +0000 (17:46 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 7 Oct 2018 15:46:42 +0000 (17:46 +0200)
Problem:    Ml_get error and crash when using "do".
Solution:   Adjust cursor position also when diffupdate is not needed.
            (Hirohito Higashi)

src/diff.c
src/testdir/test_diffmode.vim
src/version.c

index d63bd9373f9849c605221b560ff4ed3a5c45d272..054924e67e8548053f4fa75d6eb562d3fae28cb7 100644 (file)
@@ -2848,18 +2848,19 @@ ex_diffgetput(exarg_T *eap)
 theend:
     diff_busy = FALSE;
     if (diff_need_update)
-    {
-       diff_need_update = FALSE;
        ex_diffupdate(NULL);
-    }
+
+    // Check that the cursor is on a valid character and update it's
+    // position.  When there were filler lines the topline has become
+    // invalid.
+    check_cursor();
+    changed_line_abv_curs();
+
+    if (diff_need_update)
+       // redraw already done by ex_diffupdate()
+       diff_need_update = FALSE;
     else
     {
-       // Check that the cursor is on a valid character and update it's
-       // position.  When there were filler lines the topline has become
-       // invalid.
-       check_cursor();
-       changed_line_abv_curs();
-
        // Also need to redraw the other buffers.
        diff_redraw(FALSE);
        apply_autocmds(EVENT_DIFFUPDATED, NULL, NULL, FALSE, curbuf);
index 760440a9b48a59e5651e7792cd559f13ec53f7c5..e1da19fefe3a22fa7bc1274910ef05162b146c8c 100644 (file)
@@ -277,6 +277,28 @@ func Test_dp_do_buffer()
   %bwipe!
 endfunc
 
+func Test_do_lastline()
+  e! one
+  call setline(1, ['1','2','3','4','5','6'])
+  diffthis
+
+  new two
+  call setline(1, ['2','4','5'])
+  diffthis
+
+  1
+  norm dp]c
+  norm dp]c
+  wincmd w
+  call assert_equal(4, line('$'))
+  norm G
+  norm do
+  call assert_equal(3, line('$'))
+
+  windo diffoff
+  %bwipe!
+endfunc
+
 func Test_diffoff()
   enew!
   call setline(1, ['Two', 'Three'])
index f701c2521b758ca96f34219576cda0f2feec7d3c..b25f1324553053c0dfbe9fc4ab9ea959c428add1 100644 (file)
@@ -792,6 +792,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    458,
 /**/
     457,
 /**/