aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatolii Sakhnik <sakhnik@gmail.com>2018-12-09 19:55:08 +0200
committerAnatolii Sakhnik <sakhnik@gmail.com>2018-12-09 19:55:08 +0200
commite104228b1c89022f0b284753ff92deb2e9374c5b (patch)
tree59bdf9341826eea33ba7b33a1f489868f666ffcb
parentfe0114ec414108d544da73c3147fd67079f6cc2e (diff)
downloadrneovim-e104228b1c89022f0b284753ff92deb2e9374c5b.tar.gz
rneovim-e104228b1c89022f0b284753ff92deb2e9374c5b.tar.bz2
rneovim-e104228b1c89022f0b284753ff92deb2e9374c5b.zip
vim-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) https://github.com/vim/vim/commit/df77cef92ec034796723ffa3adb12e8b46daa98e
-rw-r--r--src/nvim/diff.c18
-rw-r--r--src/nvim/testdir/test_diffmode.vim22
2 files changed, 33 insertions, 7 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index b9376c311f..57bfc8db69 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -2739,15 +2739,19 @@ void ex_diffgetput(exarg_T *eap)
theend:
diff_busy = false;
if (diff_need_update) {
- 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();
+ }
+
+ // 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 {
// Also need to redraw the other buffers.
diff_redraw(false);
apply_autocmds(EVENT_DIFFUPDATED, NULL, NULL, false, curbuf);
diff --git a/src/nvim/testdir/test_diffmode.vim b/src/nvim/testdir/test_diffmode.vim
index 6f25179ab1..f34c2fd26d 100644
--- a/src/nvim/testdir/test_diffmode.vim
+++ b/src/nvim/testdir/test_diffmode.vim
@@ -275,6 +275,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'])