Skip to content

Commit f29a82d

Browse files
committed
patch 7.4.974
Problem: When using :diffsplit the cursor jumps to the first line. Solution: Put the cursor on the line related to where the cursor was before the split.
1 parent 6f62fed commit f29a82d

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/diff.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,7 @@ ex_diffsplit(eap)
10871087
exarg_T *eap;
10881088
{
10891089
win_T *old_curwin = curwin;
1090+
buf_T *old_curbuf = curbuf;
10901091

10911092
#ifdef FEAT_GUI
10921093
need_mouse_correct = TRUE;
@@ -1105,7 +1106,18 @@ ex_diffsplit(eap)
11051106
{
11061107
/* Set 'diff', 'scrollbind' on and 'wrap' off. */
11071108
diff_win_options(curwin, TRUE);
1108-
diff_win_options(old_curwin, TRUE);
1109+
if (win_valid(old_curwin))
1110+
{
1111+
diff_win_options(old_curwin, TRUE);
1112+
1113+
if (buf_valid(old_curbuf))
1114+
/* Move the cursor position to that of the old window. */
1115+
curwin->w_cursor.lnum = diff_get_corresponding_line(
1116+
old_curbuf,
1117+
old_curwin->w_cursor.lnum,
1118+
curbuf,
1119+
curwin->w_cursor.lnum);
1120+
}
11091121
}
11101122
}
11111123
}
@@ -2541,7 +2553,6 @@ diff_move_to(dir, count)
25412553
return OK;
25422554
}
25432555

2544-
#if defined(FEAT_CURSORBIND) || defined(PROTO)
25452556
linenr_T
25462557
diff_get_corresponding_line(buf1, lnum1, buf2, lnum3)
25472558
buf_T *buf1;
@@ -2610,7 +2621,6 @@ diff_get_corresponding_line(buf1, lnum1, buf2, lnum3)
26102621

26112622
return lnum2;
26122623
}
2613-
#endif
26142624

26152625
#if defined(FEAT_FOLDING) || defined(PROTO)
26162626
/*

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
974,
744746
/**/
745747
973,
746748
/**/

0 commit comments

Comments
 (0)