aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoroni-link <knil.ino@gmail.com>2014-05-22 10:59:59 +0200
committerJustin M. Keyes <justinkz@gmail.com>2014-06-05 18:13:17 -0400
commitfee0e2d977264cd21c9f833937dd56e3ffd4ea60 (patch)
treec7b12557e3fbf5df251a41777012309f35b2be11 /src
parent862a25f96e805aa7ef0912c3d50530a3eb350aeb (diff)
downloadrneovim-fee0e2d977264cd21c9f833937dd56e3ffd4ea60.tar.gz
rneovim-fee0e2d977264cd21c9f833937dd56e3ffd4ea60.tar.bz2
rneovim-fee0e2d977264cd21c9f833937dd56e3ffd4ea60.zip
vim-patch:7.4.280 #745
Problem: When using a session file the relative position of the cursor is not restored if there is another tab. (Nobuhiro Takasaki) Solution: Update w_wrow before calculating the fraction. https://code.google.com/p/vim/source/detail?r=daf7e98675cf395e1ef96f8040567affb2782a11
Diffstat (limited to 'src')
-rw-r--r--src/nvim/version.c2
-rw-r--r--src/nvim/window.c22
2 files changed, 17 insertions, 7 deletions
diff --git a/src/nvim/version.c b/src/nvim/version.c
index 40ba96c758..0d872b7291 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -207,7 +207,7 @@ static int included_patches[] = {
//283,
//282,
//281,
- //280,
+ 280,
//279,
//278,
277,
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 906a5a14d8..e0af0abc51 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -4457,8 +4457,8 @@ void win_drag_vsep_line(win_T *dragwin, int offset)
*/
static void set_fraction(win_T *wp)
{
- wp->w_fraction = ((long)wp->w_wrow * FRACTION_MULT
- + FRACTION_MULT / 2) / (long)wp->w_height;
+ wp->w_fraction = ((long)wp->w_wrow * FRACTION_MULT + wp->w_height / 2)
+ / (long)wp->w_height;
}
/*
@@ -4470,6 +4470,7 @@ 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.
* Will equalize heights soon to fix it. */
@@ -4478,8 +4479,14 @@ void win_new_height(win_T *wp, int height)
if (wp->w_height == height)
return; /* nothing to do */
- if (wp->w_wrow != wp->w_prev_fraction_row && wp->w_height > 0)
- set_fraction(wp);
+ if (wp->w_height > 0) {
+ if (wp == curwin) {
+ validate_cursor(); // w_wrow needs to be valid
+ }
+ if (wp->w_wrow != wp->w_prev_fraction_row) {
+ set_fraction(wp);
+ }
+ }
wp->w_height = height;
wp->w_skipcol = 0;
@@ -4496,7 +4503,8 @@ void win_new_height(win_T *wp, int height)
lnum = wp->w_cursor.lnum;
if (lnum < 1) /* can happen when starting up */
lnum = 1;
- wp->w_wrow = ((long)wp->w_fraction * (long)height - 1L) / FRACTION_MULT;
+ wp->w_wrow = ((long)wp->w_fraction * (long)height - 1L + FRACTION_MULT / 2)
+ / FRACTION_MULT;
line_size = plines_win_col(wp, lnum, (long)(wp->w_cursor.col)) - 1;
sline = wp->w_wrow - line_size;
@@ -4567,7 +4575,9 @@ void win_new_height(win_T *wp, int height)
update_topline();
curs_columns(FALSE); /* validate w_wrow */
}
- wp->w_prev_fraction_row = wp->w_wrow;
+ if (prev_height > 0) {
+ wp->w_prev_fraction_row = wp->w_wrow;
+ }
win_comp_scroll(wp);
redraw_win_later(wp, SOME_VALID);