diff options
Diffstat (limited to 'src/nvim/diff.c')
| -rw-r--r-- | src/nvim/diff.c | 16 | 
1 files changed, 14 insertions, 2 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c index d311588ab4..ce79158050 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -1007,6 +1007,7 @@ theend:  void ex_diffsplit(exarg_T *eap)  {    win_T *old_curwin = curwin; +  buf_T *old_curbuf = curbuf;    // don't use a new tab page, each tab page has its own diffs    cmdmod.tab = 0; @@ -1020,8 +1021,19 @@ void ex_diffsplit(exarg_T *eap)      // split must have worked      if (curwin != old_curwin) {        // Set 'diff', 'scrollbind' on and 'wrap' off. -      diff_win_options(curwin, TRUE); -      diff_win_options(old_curwin, TRUE); +      diff_win_options(curwin, true); +      if (win_valid(old_curwin)) { +        diff_win_options(old_curwin, true); + +        if (buf_valid(old_curbuf)) { +          // Move the cursor position to that of the old window. +          curwin->w_cursor.lnum = diff_get_corresponding_line( +              old_curbuf, +              old_curwin->w_cursor.lnum, +              curbuf, +              curwin->w_cursor.lnum); +        } +      }      }    }  }  | 
