1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
To: vim-dev@vim.org
Subject: Patch 7.2.042
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------
Patch 7.2.042
Problem: When using winrestview() in a BufWinEnter autocommand the window
is scrolled anyway. (Matt Zyzik)
Solution: Don't recompute topline when above 'scrolloff' from the bottom.
Don't always put the cursor halfway when entering a buffer. Add
"w_topline_was_set".
Files: src/buffer.c, src/move.c, src/structs.h
*** ../vim-7.2.041/src/buffer.c Sat Nov 15 14:10:23 2008
--- src/buffer.c Sat Nov 15 14:58:52 2008
***************
*** 1401,1406 ****
--- 1401,1409 ----
curwin->w_cursor.coladd = 0;
#endif
curwin->w_set_curswant = TRUE;
+ #ifdef FEAT_AUTOCMD
+ curwin->w_topline_was_set = FALSE;
+ #endif
/* Make sure the buffer is loaded. */
if (curbuf->b_ml.ml_mfp == NULL) /* need to load the file */
***************
*** 1440,1446 ****
maketitle();
#endif
#ifdef FEAT_AUTOCMD
! if (curwin->w_topline == 1) /* when autocmds didn't change it */
#endif
scroll_cursor_halfway(FALSE); /* redisplay at correct position */
--- 1443,1450 ----
maketitle();
#endif
#ifdef FEAT_AUTOCMD
! /* when autocmds didn't change it */
! if (curwin->w_topline == 1 && !curwin->w_topline_was_set)
#endif
scroll_cursor_halfway(FALSE); /* redisplay at correct position */
*** ../vim-7.2.041/src/move.c Sun Jul 13 19:25:23 2008
--- src/move.c Sat Nov 15 14:56:47 2008
***************
*** 280,297 ****
if (curwin->w_botline <= curbuf->b_ml.ml_line_count)
{
! if (curwin->w_cursor.lnum < curwin->w_botline
! && ((long)curwin->w_cursor.lnum
>= (long)curwin->w_botline - p_so
#ifdef FEAT_FOLDING
|| hasAnyFolding(curwin)
#endif
))
! {
lineoff_T loff;
! /* Cursor is above botline, check if there are 'scrolloff'
! * window lines below the cursor. If not, need to scroll. */
n = curwin->w_empty_rows;
loff.lnum = curwin->w_cursor.lnum;
#ifdef FEAT_FOLDING
--- 280,299 ----
if (curwin->w_botline <= curbuf->b_ml.ml_line_count)
{
! if (curwin->w_cursor.lnum < curwin->w_botline)
! {
! if (((long)curwin->w_cursor.lnum
>= (long)curwin->w_botline - p_so
#ifdef FEAT_FOLDING
|| hasAnyFolding(curwin)
#endif
))
! {
lineoff_T loff;
! /* Cursor is (a few lines) above botline, check if there are
! * 'scrolloff' window lines below the cursor. If not, need to
! * scroll. */
n = curwin->w_empty_rows;
loff.lnum = curwin->w_cursor.lnum;
#ifdef FEAT_FOLDING
***************
*** 317,322 ****
--- 319,328 ----
if (n >= p_so)
/* sufficient context, no need to scroll */
check_botline = FALSE;
+ }
+ else
+ /* sufficient context, no need to scroll */
+ check_botline = FALSE;
}
if (check_botline)
{
***************
*** 509,514 ****
--- 515,523 ----
/* Approximate the value of w_botline */
wp->w_botline += lnum - wp->w_topline;
wp->w_topline = lnum;
+ #ifdef FEAT_AUTOCMD
+ wp->w_topline_was_set = TRUE;
+ #endif
#ifdef FEAT_DIFF
wp->w_topfill = 0;
#endif
*** ../vim-7.2.041/src/structs.h Sun Nov 9 13:43:25 2008
--- src/structs.h Sat Nov 15 14:56:42 2008
***************
*** 1784,1793 ****
#endif
/*
! * The next three specify the offsets for displaying the buffer:
*/
linenr_T w_topline; /* buffer line number of the line at the
top of the window */
#ifdef FEAT_DIFF
int w_topfill; /* number of filler lines above w_topline */
int w_old_topfill; /* w_topfill at last redraw */
--- 1784,1798 ----
#endif
/*
! * "w_topline", "w_leftcol" and "w_skipcol" specify the offsets for
! * displaying the buffer.
*/
linenr_T w_topline; /* buffer line number of the line at the
top of the window */
+ #ifdef FEAT_AUTOCMD
+ char w_topline_was_set; /* flag set to TRUE when topline is set,
+ e.g. by winrestview() */
+ #endif
#ifdef FEAT_DIFF
int w_topfill; /* number of filler lines above w_topline */
int w_old_topfill; /* w_topfill at last redraw */
*** ../vim-7.2.041/src/version.c Sat Nov 15 14:10:23 2008
--- src/version.c Sat Nov 15 16:01:29 2008
***************
*** 678,679 ****
--- 678,681 ----
{ /* Add new patch number below this line */
+ /**/
+ 42,
/**/
--
hundred-and-one symptoms of being an internet addict:
261. You find diskettes in your pockets when doing laundry.
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|