4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
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
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
24 ml_delete(eap->line1, FALSE);
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));
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
36 if (*ml_get(lnum) == NUL && u_savedel(lnum, 1L) == OK)
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;
45 redraw_curbuf_later(VALID);
47 if (*ml_get(lnum) == NUL && u_savedel(lnum, 1L) == OK)
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);
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
62 raise_vim_exn(_("cannot delete line"));
64 - deleted_lines_mark((linenr_T)n, 1L);
65 if (buf->buf == curwin->w_buffer)
66 mz_fix_cursor(n, n + 1, -1);
72 raise_vim_exn(_("cannot delete line"));
74 if (buf->buf == curwin->w_buffer)
75 mz_fix_cursor(n, n + 1, -1);
76 + deleted_lines_mark((linenr_T)n, 1L);
83 raise_vim_exn(_("cannot delete line"));
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);
93 raise_vim_exn(_("cannot delete line"));
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);
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
105 PyErr_SetVim(_("cannot delete line"));
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);
115 PyErr_SetVim(_("cannot delete line"));
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);
129 - deleted_lines_mark((linenr_T)lo, (long)i);
131 if (buf == curwin->w_buffer)
132 py_fix_cursor((linenr_T)lo, (linenr_T)hi, (linenr_T)-n);
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);
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
150 if (u_savedel(lnum, 1) == OK)
153 deleted_lines_mark(lnum, 1L);
154 - if (aco.save_curbuf == curbuf)
158 /* restore curwin/curbuf and a few other things */
160 if (u_savedel(lnum, 1) == OK)
164 deleted_lines_mark(lnum, 1L);
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
172 int undo; /* if TRUE, prepare for undo */
179 /* save the deleted lines for undo */
180 ! if (undo && u_savedel(curwin->w_cursor.lnum, nlines) == FAIL)
183 for (n = 0; n < nlines; )
185 int undo; /* if TRUE, prepare for undo */
188 + linenr_T first = curwin->w_cursor.lnum;
193 /* save the deleted lines for undo */
194 ! if (undo && u_savedel(first, nlines) == FAIL)
197 for (n = 0; n < nlines; )
200 if (curbuf->b_ml.ml_flags & ML_EMPTY) /* nothing to delete */
203 ! ml_delete(curwin->w_cursor.lnum, TRUE);
206 /* If we delete the last line in the file, stop */
207 ! if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
210 - /* adjust marks, mark the buffer as changed and prepare for displaying */
211 - deleted_lines_mark(curwin->w_cursor.lnum, n);
213 curwin->w_cursor.col = 0;
219 if (curbuf->b_ml.ml_flags & ML_EMPTY) /* nothing to delete */
222 ! ml_delete(first, TRUE);
225 /* If we delete the last line in the file, stop */
226 ! if (first > curbuf->b_ml.ml_line_count)
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;
235 + /* adjust marks, mark the buffer as changed and prepare for displaying */
236 + deleted_lines_mark(first, n);
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.
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
256 { /* Add new patch number below this line */
262 hundred-and-one symptoms of being an internet addict:
263 80. At parties, you introduce your spouse as your "service provider."
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 ///