4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: When using winrestview() in a BufWinEnter autocommand the window
12 is scrolled anyway. (Matt Zyzik)
13 Solution: Don't recompute topline when above 'scrolloff' from the bottom.
14 Don't always put the cursor halfway when entering a buffer. Add
16 Files: src/buffer.c, src/move.c, src/structs.h
19 *** ../vim-7.2.041/src/buffer.c Sat Nov 15 14:10:23 2008
20 --- src/buffer.c Sat Nov 15 14:58:52 2008
24 curwin->w_cursor.coladd = 0;
26 curwin->w_set_curswant = TRUE;
28 + curwin->w_topline_was_set = FALSE;
31 /* Make sure the buffer is loaded. */
32 if (curbuf->b_ml.ml_mfp == NULL) /* need to load the file */
38 ! if (curwin->w_topline == 1) /* when autocmds didn't change it */
40 scroll_cursor_halfway(FALSE); /* redisplay at correct position */
46 ! /* when autocmds didn't change it */
47 ! if (curwin->w_topline == 1 && !curwin->w_topline_was_set)
49 scroll_cursor_halfway(FALSE); /* redisplay at correct position */
51 *** ../vim-7.2.041/src/move.c Sun Jul 13 19:25:23 2008
52 --- src/move.c Sat Nov 15 14:56:47 2008
56 if (curwin->w_botline <= curbuf->b_ml.ml_line_count)
58 ! if (curwin->w_cursor.lnum < curwin->w_botline
59 ! && ((long)curwin->w_cursor.lnum
60 >= (long)curwin->w_botline - p_so
62 || hasAnyFolding(curwin)
68 ! /* Cursor is above botline, check if there are 'scrolloff'
69 ! * window lines below the cursor. If not, need to scroll. */
70 n = curwin->w_empty_rows;
71 loff.lnum = curwin->w_cursor.lnum;
75 if (curwin->w_botline <= curbuf->b_ml.ml_line_count)
77 ! if (curwin->w_cursor.lnum < curwin->w_botline)
79 ! if (((long)curwin->w_cursor.lnum
80 >= (long)curwin->w_botline - p_so
82 || hasAnyFolding(curwin)
88 ! /* Cursor is (a few lines) above botline, check if there are
89 ! * 'scrolloff' window lines below the cursor. If not, need to
91 n = curwin->w_empty_rows;
92 loff.lnum = curwin->w_cursor.lnum;
98 /* sufficient context, no need to scroll */
99 check_botline = FALSE;
102 + /* sufficient context, no need to scroll */
103 + check_botline = FALSE;
110 /* Approximate the value of w_botline */
111 wp->w_botline += lnum - wp->w_topline;
112 wp->w_topline = lnum;
113 + #ifdef FEAT_AUTOCMD
114 + wp->w_topline_was_set = TRUE;
119 *** ../vim-7.2.041/src/structs.h Sun Nov 9 13:43:25 2008
120 --- src/structs.h Sat Nov 15 14:56:42 2008
126 ! * The next three specify the offsets for displaying the buffer:
128 linenr_T w_topline; /* buffer line number of the line at the
131 int w_topfill; /* number of filler lines above w_topline */
132 int w_old_topfill; /* w_topfill at last redraw */
137 ! * "w_topline", "w_leftcol" and "w_skipcol" specify the offsets for
138 ! * displaying the buffer.
140 linenr_T w_topline; /* buffer line number of the line at the
142 + #ifdef FEAT_AUTOCMD
143 + char w_topline_was_set; /* flag set to TRUE when topline is set,
144 + e.g. by winrestview() */
147 int w_topfill; /* number of filler lines above w_topline */
148 int w_old_topfill; /* w_topfill at last redraw */
149 *** ../vim-7.2.041/src/version.c Sat Nov 15 14:10:23 2008
150 --- src/version.c Sat Nov 15 16:01:29 2008
154 { /* Add new patch number below this line */
160 hundred-and-one symptoms of being an internet addict:
161 261. You find diskettes in your pockets when doing laundry.
163 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
164 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
165 \\\ download, build and distribute -- http://www.A-A-P.org ///
166 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///