# HG changeset patch # User Bram Moolenaar # Date 1538928005 -7200 # Node ID 291656f731c933c043c6f925d155c2be2169a044 # Parent 983b36c27a2ba500fc5a307bcef3b8a001afa3a8 patch 8.1.0458: ml_get error and crash when using "do" commit https://github.com/vim/vim/commit/df77cef92ec034796723ffa3adb12e8b46daa98e Author: Bram Moolenaar Date: Sun Oct 7 17:46:42 2018 +0200 patch 8.1.0458: ml_get error and crash when using "do" Problem: Ml_get error and crash when using "do". Solution: Adjust cursor position also when diffupdate is not needed. (Hirohito Higashi) diff --git a/src/diff.c b/src/diff.c --- a/src/diff.c +++ b/src/diff.c @@ -2848,18 +2848,19 @@ ex_diffgetput(exarg_T *eap) theend: diff_busy = FALSE; if (diff_need_update) - { + 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; - ex_diffupdate(NULL); - } 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); diff --git a/src/testdir/test_diffmode.vim b/src/testdir/test_diffmode.vim --- a/src/testdir/test_diffmode.vim +++ b/src/testdir/test_diffmode.vim @@ -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']) diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -793,6 +793,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 458, +/**/ 457, /**/ 456,