Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

updated for version 7.3.084

Problem:    When splitting the window, the new one scrolls with the cursor at
	    the top.
Solution:   Compute w_fraction before setting the new height.
  • Loading branch information...
commit 3017c44c4bb1fc58c35e17293602b7369541e5eb 1 parent 25ac995
Bram Moolenaar authored

Showing 2 changed files with 24 additions and 4 deletions. Show diff stats Hide diff stats

  1. +2 0  src/version.c
  2. +22 4 src/window.c
2  src/version.c
@@ -715,6 +715,8 @@ static char *(features[]) =
715 715 static int included_patches[] =
716 716 { /* Add new patch number below this line */
717 717 /**/
  718 + 84,
  719 +/**/
718 720 83,
719 721 /**/
720 722 82,
26 src/window.c
@@ -70,7 +70,8 @@ static win_T *restore_snapshot_rec __ARGS((frame_T *sn, frame_T *fr));
70 70 #endif /* FEAT_WINDOWS */
71 71
72 72 static win_T *win_alloc __ARGS((win_T *after, int hidden));
73   -static void win_new_height __ARGS((win_T *, int));
  73 +static void set_fraction __ARGS((win_T *wp));
  74 +static void win_new_height __ARGS((win_T *wp, int height));
74 75
75 76 #define URL_SLASH 1 /* path_is_url() has found "://" */
76 77 #define URL_BACKSLASH 2 /* path_is_url() has found ":\\" */
@@ -983,10 +984,16 @@ win_split_ins(size, flags, newwin, dir)
983 984 else
984 985 frame_append(curfrp, frp);
985 986
  987 + /* Set w_fraction now so that the cursor keeps the same relative
  988 + * vertical position. */
  989 + set_fraction(oldwin);
  990 + wp->w_fraction = oldwin->w_fraction;
  991 +
986 992 #ifdef FEAT_VERTSPLIT
987 993 if (flags & WSP_VERT)
988 994 {
989 995 wp->w_p_scr = curwin->w_p_scr;
  996 +
990 997 if (need_status)
991 998 {
992 999 win_new_height(oldwin, oldwin->w_height - 1);
@@ -5453,6 +5460,19 @@ win_drag_vsep_line(dragwin, offset)
5453 5460
5454 5461 #endif /* FEAT_WINDOWS */
5455 5462
  5463 +#define FRACTION_MULT 16384L
  5464 +
  5465 +/*
  5466 + * Set wp->w_fraction for the current w_wrow and w_height.
  5467 + */
  5468 + static void
  5469 +set_fraction(wp)
  5470 + win_T *wp;
  5471 +{
  5472 + wp->w_fraction = ((long)wp->w_wrow * FRACTION_MULT
  5473 + + FRACTION_MULT / 2) / (long)wp->w_height;
  5474 +}
  5475 +
5456 5476 /*
5457 5477 * Set the height of a window.
5458 5478 * This takes care of the things inside the window, not what happens to the
@@ -5465,7 +5485,6 @@ win_new_height(wp, height)
5465 5485 {
5466 5486 linenr_T lnum;
5467 5487 int sline, line_size;
5468   -#define FRACTION_MULT 16384L
5469 5488
5470 5489 /* Don't want a negative height. Happens when splitting a tiny window.
5471 5490 * Will equalize heights soon to fix it. */
@@ -5475,8 +5494,7 @@ win_new_height(wp, height)
5475 5494 return; /* nothing to do */
5476 5495
5477 5496 if (wp->w_wrow != wp->w_prev_fraction_row && wp->w_height > 0)
5478   - wp->w_fraction = ((long)wp->w_wrow * FRACTION_MULT
5479   - + FRACTION_MULT / 2) / (long)wp->w_height;
  5497 + set_fraction(wp);
5480 5498
5481 5499 wp->w_height = height;
5482 5500 wp->w_skipcol = 0;

0 comments on commit 3017c44

Please sign in to comment.
Something went wrong with that request. Please try again.