]>
Commit | Line | Data |
---|---|---|
39a54fe5 AG |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 7.2.226 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.2.226 | |
11 | Problem: ml_get error after deleting the last line. (Xavier de Gaye) | |
12 | Solution: When adjusting marks a callback may be invoked. Adjust the cursor | |
13 | position before invoking deleted_lines_mark(). | |
14 | Files: src/ex_cmds.c, src/ex_docmd.c, src/if_mzsch.c, src/if_python.c, | |
15 | src/if_perl.xs, src/misc1.c | |
16 | ||
17 | ||
18 | *** ../vim-7.2.225/src/ex_cmds.c 2009-05-17 13:30:58.000000000 +0200 | |
19 | --- src/ex_cmds.c 2009-07-09 12:56:51.000000000 +0200 | |
20 | *************** | |
21 | *** 4013,4018 **** | |
22 | --- 4013,4021 ---- | |
23 | break; | |
24 | ml_delete(eap->line1, FALSE); | |
25 | } | |
26 | + | |
27 | + /* make sure the cursor is not beyond the end of the file now */ | |
28 | + check_cursor_lnum(); | |
29 | deleted_lines_mark(eap->line1, (long)(eap->line2 - lnum)); | |
30 | ||
31 | /* ":append" on the line above the deleted lines. */ | |
32 | *** ../vim-7.2.225/src/ex_docmd.c 2009-07-09 15:55:34.000000000 +0200 | |
33 | --- src/ex_docmd.c 2009-07-09 15:24:03.000000000 +0200 | |
34 | *************** | |
35 | *** 7845,7854 **** | |
36 | if (*ml_get(lnum) == NUL && u_savedel(lnum, 1L) == OK) | |
37 | { | |
38 | ml_delete(lnum, FALSE); | |
39 | - deleted_lines_mark(lnum, 1L); | |
40 | if (curwin->w_cursor.lnum > 1 | |
41 | && curwin->w_cursor.lnum >= lnum) | |
42 | --curwin->w_cursor.lnum; | |
43 | } | |
44 | } | |
45 | redraw_curbuf_later(VALID); | |
46 | --- 7845,7854 ---- | |
47 | if (*ml_get(lnum) == NUL && u_savedel(lnum, 1L) == OK) | |
48 | { | |
49 | ml_delete(lnum, FALSE); | |
50 | if (curwin->w_cursor.lnum > 1 | |
51 | && curwin->w_cursor.lnum >= lnum) | |
52 | --curwin->w_cursor.lnum; | |
53 | + deleted_lines_mark(lnum, 1L); | |
54 | } | |
55 | } | |
56 | redraw_curbuf_later(VALID); | |
57 | *** ../vim-7.2.225/src/if_mzsch.c 2009-06-24 17:51:01.000000000 +0200 | |
58 | --- src/if_mzsch.c 2009-07-09 12:59:17.000000000 +0200 | |
59 | *************** | |
60 | *** 2169,2177 **** | |
61 | curbuf = savebuf; | |
62 | raise_vim_exn(_("cannot delete line")); | |
63 | } | |
64 | - deleted_lines_mark((linenr_T)n, 1L); | |
65 | if (buf->buf == curwin->w_buffer) | |
66 | mz_fix_cursor(n, n + 1, -1); | |
67 | ||
68 | curbuf = savebuf; | |
69 | ||
70 | --- 2169,2177 ---- | |
71 | curbuf = savebuf; | |
72 | raise_vim_exn(_("cannot delete line")); | |
73 | } | |
74 | if (buf->buf == curwin->w_buffer) | |
75 | mz_fix_cursor(n, n + 1, -1); | |
76 | + deleted_lines_mark((linenr_T)n, 1L); | |
77 | ||
78 | curbuf = savebuf; | |
79 | ||
80 | *************** | |
81 | *** 2299,2307 **** | |
82 | curbuf = savebuf; | |
83 | raise_vim_exn(_("cannot delete line")); | |
84 | } | |
85 | - deleted_lines_mark((linenr_T)lo, (long)old_len); | |
86 | if (buf->buf == curwin->w_buffer) | |
87 | mz_fix_cursor(lo, hi, -old_len); | |
88 | } | |
89 | ||
90 | curbuf = savebuf; | |
91 | --- 2299,2307 ---- | |
92 | curbuf = savebuf; | |
93 | raise_vim_exn(_("cannot delete line")); | |
94 | } | |
95 | if (buf->buf == curwin->w_buffer) | |
96 | mz_fix_cursor(lo, hi, -old_len); | |
97 | + deleted_lines_mark((linenr_T)lo, (long)old_len); | |
98 | } | |
99 | ||
100 | curbuf = savebuf; | |
101 | *** ../vim-7.2.225/src/if_python.c 2009-05-21 23:25:38.000000000 +0200 | |
102 | --- src/if_python.c 2009-07-09 12:59:45.000000000 +0200 | |
103 | *************** | |
104 | *** 2497,2505 **** | |
105 | PyErr_SetVim(_("cannot delete line")); | |
106 | else | |
107 | { | |
108 | - deleted_lines_mark((linenr_T)n, 1L); | |
109 | if (buf == curwin->w_buffer) | |
110 | py_fix_cursor((linenr_T)n, (linenr_T)n + 1, (linenr_T)-1); | |
111 | } | |
112 | ||
113 | curbuf = savebuf; | |
114 | --- 2497,2505 ---- | |
115 | PyErr_SetVim(_("cannot delete line")); | |
116 | else | |
117 | { | |
118 | if (buf == curwin->w_buffer) | |
119 | py_fix_cursor((linenr_T)n, (linenr_T)n + 1, (linenr_T)-1); | |
120 | + deleted_lines_mark((linenr_T)n, 1L); | |
121 | } | |
122 | ||
123 | curbuf = savebuf; | |
124 | *************** | |
125 | *** 2596,2605 **** | |
126 | break; | |
127 | } | |
128 | } | |
129 | - deleted_lines_mark((linenr_T)lo, (long)i); | |
130 | - | |
131 | if (buf == curwin->w_buffer) | |
132 | py_fix_cursor((linenr_T)lo, (linenr_T)hi, (linenr_T)-n); | |
133 | } | |
134 | ||
135 | curbuf = savebuf; | |
136 | --- 2596,2604 ---- | |
137 | break; | |
138 | } | |
139 | } | |
140 | if (buf == curwin->w_buffer) | |
141 | py_fix_cursor((linenr_T)lo, (linenr_T)hi, (linenr_T)-n); | |
142 | + deleted_lines_mark((linenr_T)lo, (long)i); | |
143 | } | |
144 | ||
145 | curbuf = savebuf; | |
146 | *** ../vim-7.2.225/src/if_perl.xs 2009-06-16 16:01:34.000000000 +0200 | |
147 | --- src/if_perl.xs 2009-07-09 13:02:16.000000000 +0200 | |
148 | *************** | |
149 | *** 1233,1241 **** | |
150 | if (u_savedel(lnum, 1) == OK) | |
151 | { | |
152 | ml_delete(lnum, 0); | |
153 | deleted_lines_mark(lnum, 1L); | |
154 | - if (aco.save_curbuf == curbuf) | |
155 | - check_cursor(); | |
156 | } | |
157 | ||
158 | /* restore curwin/curbuf and a few other things */ | |
159 | --- 1235,1242 ---- | |
160 | if (u_savedel(lnum, 1) == OK) | |
161 | { | |
162 | ml_delete(lnum, 0); | |
163 | + check_cursor(); | |
164 | deleted_lines_mark(lnum, 1L); | |
165 | } | |
166 | ||
167 | /* restore curwin/curbuf and a few other things */ | |
168 | *** ../vim-7.2.225/src/misc1.c 2009-06-24 16:25:23.000000000 +0200 | |
169 | --- src/misc1.c 2009-07-09 13:00:59.000000000 +0200 | |
170 | *************** | |
171 | *** 2345,2356 **** | |
172 | int undo; /* if TRUE, prepare for undo */ | |
173 | { | |
174 | long n; | |
175 | ||
176 | if (nlines <= 0) | |
177 | return; | |
178 | ||
179 | /* save the deleted lines for undo */ | |
180 | ! if (undo && u_savedel(curwin->w_cursor.lnum, nlines) == FAIL) | |
181 | return; | |
182 | ||
183 | for (n = 0; n < nlines; ) | |
184 | --- 2345,2357 ---- | |
185 | int undo; /* if TRUE, prepare for undo */ | |
186 | { | |
187 | long n; | |
188 | + linenr_T first = curwin->w_cursor.lnum; | |
189 | ||
190 | if (nlines <= 0) | |
191 | return; | |
192 | ||
193 | /* save the deleted lines for undo */ | |
194 | ! if (undo && u_savedel(first, nlines) == FAIL) | |
195 | return; | |
196 | ||
197 | for (n = 0; n < nlines; ) | |
198 | *************** | |
199 | *** 2358,2375 **** | |
200 | if (curbuf->b_ml.ml_flags & ML_EMPTY) /* nothing to delete */ | |
201 | break; | |
202 | ||
203 | ! ml_delete(curwin->w_cursor.lnum, TRUE); | |
204 | ++n; | |
205 | ||
206 | /* If we delete the last line in the file, stop */ | |
207 | ! if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) | |
208 | break; | |
209 | } | |
210 | - /* adjust marks, mark the buffer as changed and prepare for displaying */ | |
211 | - deleted_lines_mark(curwin->w_cursor.lnum, n); | |
212 | ||
213 | curwin->w_cursor.col = 0; | |
214 | check_cursor_lnum(); | |
215 | } | |
216 | ||
217 | int | |
218 | --- 2359,2379 ---- | |
219 | if (curbuf->b_ml.ml_flags & ML_EMPTY) /* nothing to delete */ | |
220 | break; | |
221 | ||
222 | ! ml_delete(first, TRUE); | |
223 | ++n; | |
224 | ||
225 | /* If we delete the last line in the file, stop */ | |
226 | ! if (first > curbuf->b_ml.ml_line_count) | |
227 | break; | |
228 | } | |
229 | ||
230 | + /* Correct the cursor position before calling deleted_lines_mark(), it may | |
231 | + * trigger a callback to display the cursor. */ | |
232 | curwin->w_cursor.col = 0; | |
233 | check_cursor_lnum(); | |
234 | + | |
235 | + /* adjust marks, mark the buffer as changed and prepare for displaying */ | |
236 | + deleted_lines_mark(first, n); | |
237 | } | |
238 | ||
239 | int | |
240 | *************** | |
241 | *** 2621,2626 **** | |
242 | --- 2625,2632 ---- | |
243 | ||
244 | /* | |
245 | * Like deleted_lines(), but adjust marks first. | |
246 | + * Make sure the cursor is on a valid line before calling, a GUI callback may | |
247 | + * be triggered to display the cursor. | |
248 | */ | |
249 | void | |
250 | deleted_lines_mark(lnum, count) | |
251 | *** ../vim-7.2.225/src/version.c 2009-07-09 18:24:24.000000000 +0200 | |
252 | --- src/version.c 2009-07-09 20:01:16.000000000 +0200 | |
253 | *************** | |
254 | *** 678,679 **** | |
255 | --- 678,681 ---- | |
256 | { /* Add new patch number below this line */ | |
257 | + /**/ | |
258 | + 226, | |
259 | /**/ | |
260 | ||
261 | -- | |
262 | hundred-and-one symptoms of being an internet addict: | |
263 | 80. At parties, you introduce your spouse as your "service provider." | |
264 | ||
265 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
266 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
267 | \\\ download, build and distribute -- http://www.A-A-P.org /// | |
268 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |