Mercurial > vim
comparison src/diff.c @ 7338:96d5dd9e7bc9 v7.4.974
commit https://github.com/vim/vim/commit/f29a82dcd0914c76f595d475ddac4517371fab2b
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Dec 17 15:03:55 2015 +0100
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.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 17 Dec 2015 15:15:06 +0100 |
parents | a07c3f9cd616 |
children | af3c41a3c53f |
comparison
equal
deleted
inserted
replaced
7337:18f4dcee47cb | 7338:96d5dd9e7bc9 |
---|---|
1085 void | 1085 void |
1086 ex_diffsplit(eap) | 1086 ex_diffsplit(eap) |
1087 exarg_T *eap; | 1087 exarg_T *eap; |
1088 { | 1088 { |
1089 win_T *old_curwin = curwin; | 1089 win_T *old_curwin = curwin; |
1090 buf_T *old_curbuf = curbuf; | |
1090 | 1091 |
1091 #ifdef FEAT_GUI | 1092 #ifdef FEAT_GUI |
1092 need_mouse_correct = TRUE; | 1093 need_mouse_correct = TRUE; |
1093 #endif | 1094 #endif |
1094 /* don't use a new tab page, each tab page has its own diffs */ | 1095 /* don't use a new tab page, each tab page has its own diffs */ |
1103 | 1104 |
1104 if (curwin != old_curwin) /* split must have worked */ | 1105 if (curwin != old_curwin) /* split must have worked */ |
1105 { | 1106 { |
1106 /* Set 'diff', 'scrollbind' on and 'wrap' off. */ | 1107 /* Set 'diff', 'scrollbind' on and 'wrap' off. */ |
1107 diff_win_options(curwin, TRUE); | 1108 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 } | |
1109 } | 1121 } |
1110 } | 1122 } |
1111 } | 1123 } |
1112 | 1124 |
1113 /* | 1125 /* |
2539 curwin->w_cursor.col = 0; | 2551 curwin->w_cursor.col = 0; |
2540 | 2552 |
2541 return OK; | 2553 return OK; |
2542 } | 2554 } |
2543 | 2555 |
2544 #if defined(FEAT_CURSORBIND) || defined(PROTO) | |
2545 linenr_T | 2556 linenr_T |
2546 diff_get_corresponding_line(buf1, lnum1, buf2, lnum3) | 2557 diff_get_corresponding_line(buf1, lnum1, buf2, lnum3) |
2547 buf_T *buf1; | 2558 buf_T *buf1; |
2548 linenr_T lnum1; | 2559 linenr_T lnum1; |
2549 buf_T *buf2; | 2560 buf_T *buf2; |
2608 if (lnum2 > buf2->b_ml.ml_line_count) | 2619 if (lnum2 > buf2->b_ml.ml_line_count) |
2609 lnum2 = buf2->b_ml.ml_line_count; | 2620 lnum2 = buf2->b_ml.ml_line_count; |
2610 | 2621 |
2611 return lnum2; | 2622 return lnum2; |
2612 } | 2623 } |
2613 #endif | |
2614 | 2624 |
2615 #if defined(FEAT_FOLDING) || defined(PROTO) | 2625 #if defined(FEAT_FOLDING) || defined(PROTO) |
2616 /* | 2626 /* |
2617 * For line "lnum" in the current window find the equivalent lnum in window | 2627 * For line "lnum" in the current window find the equivalent lnum in window |
2618 * "wp", compensating for inserted/deleted lines. | 2628 * "wp", compensating for inserted/deleted lines. |