diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-08-28 15:39:57 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-08-28 15:39:57 +0200 |
commit | 46328f9a1cc8047d1e05095bc9f531038c5a4028 (patch) | |
tree | 6c304ad0ec0fdaafa7e4e490681a959f36ad46f2 /src | |
parent | 4427db9bb2f4b4587559eac18cc7ba10c52c6e8b (diff) | |
download | vim-git-46328f9a1cc8047d1e05095bc9f531038c5a4028.tar.gz |
patch 7.4.2279v7.4.2279
Problem: Starting diff mode with the cursor in the last line might end up
only showing one closed fold. (John Beckett)
Solution: Scroll the window to show the same relative cursor position.
Diffstat (limited to 'src')
-rw-r--r-- | src/diff.c | 7 | ||||
-rw-r--r-- | src/proto/window.pro | 1 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/window.c | 12 |
4 files changed, 20 insertions, 2 deletions
diff --git a/src/diff.c b/src/diff.c index 35e29fcdf..05ca7ac25 100644 --- a/src/diff.c +++ b/src/diff.c @@ -1075,6 +1075,10 @@ ex_diffsplit(exarg_T *eap) #ifdef FEAT_GUI need_mouse_correct = TRUE; #endif + /* Need to compute w_fraction when no redraw happened yet. */ + validate_cursor(); + set_fraction(curwin); + /* don't use a new tab page, each tab page has its own diffs */ cmdmod.tab = 0; @@ -1101,6 +1105,9 @@ ex_diffsplit(exarg_T *eap) curbuf, curwin->w_cursor.lnum); } + /* Now that lines are folded scroll to show the cursor at the same + * relative position. */ + scroll_to_fraction(curwin, curwin->w_height); } } } diff --git a/src/proto/window.pro b/src/proto/window.pro index d82988e30..8b649dbf1 100644 --- a/src/proto/window.pro +++ b/src/proto/window.pro @@ -56,6 +56,7 @@ void win_drag_status_line(win_T *dragwin, int offset); void win_drag_vsep_line(win_T *dragwin, int offset); void set_fraction(win_T *wp); void win_new_height(win_T *wp, int height); +void scroll_to_fraction(win_T *wp, int prev_height); void win_new_width(win_T *wp, int width); void win_comp_scroll(win_T *wp); void command_height(void); diff --git a/src/version.c b/src/version.c index 6f4be8e34..007a56c59 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2279, +/**/ 2278, /**/ 2277, diff --git a/src/window.c b/src/window.c index 65d8b36ea..6943c8fe3 100644 --- a/src/window.c +++ b/src/window.c @@ -5674,8 +5674,6 @@ set_fraction(win_T *wp) void win_new_height(win_T *wp, int height) { - linenr_T lnum; - int sline, line_size; int prev_height = wp->w_height; /* Don't want a negative height. Happens when splitting a tiny window. @@ -5701,6 +5699,16 @@ win_new_height(win_T *wp, int height) wp->w_height = height; wp->w_skipcol = 0; + scroll_to_fraction(wp, prev_height); +} + + void +scroll_to_fraction(win_T *wp, int prev_height) +{ + linenr_T lnum; + int sline, line_size; + int height = wp->w_height; + /* Don't change w_topline when height is zero. Don't set w_topline when * 'scrollbind' is set and this isn't the current window. */ if (height > 0 |