269 lines
7.3 KiB
Plaintext
269 lines
7.3 KiB
Plaintext
|
To: vim-dev@vim.org
|
||
|
Subject: Patch 7.2.226
|
||
|
Fcc: outbox
|
||
|
From: Bram Moolenaar <Bram@moolenaar.net>
|
||
|
Mime-Version: 1.0
|
||
|
Content-Type: text/plain; charset=UTF-8
|
||
|
Content-Transfer-Encoding: 8bit
|
||
|
------------
|
||
|
|
||
|
Patch 7.2.226
|
||
|
Problem: ml_get error after deleting the last line. (Xavier de Gaye)
|
||
|
Solution: When adjusting marks a callback may be invoked. Adjust the cursor
|
||
|
position before invoking deleted_lines_mark().
|
||
|
Files: src/ex_cmds.c, src/ex_docmd.c, src/if_mzsch.c, src/if_python.c,
|
||
|
src/if_perl.xs, src/misc1.c
|
||
|
|
||
|
|
||
|
*** ../vim-7.2.225/src/ex_cmds.c 2009-05-17 13:30:58.000000000 +0200
|
||
|
--- src/ex_cmds.c 2009-07-09 12:56:51.000000000 +0200
|
||
|
***************
|
||
|
*** 4013,4018 ****
|
||
|
--- 4013,4021 ----
|
||
|
break;
|
||
|
ml_delete(eap->line1, FALSE);
|
||
|
}
|
||
|
+
|
||
|
+ /* make sure the cursor is not beyond the end of the file now */
|
||
|
+ check_cursor_lnum();
|
||
|
deleted_lines_mark(eap->line1, (long)(eap->line2 - lnum));
|
||
|
|
||
|
/* ":append" on the line above the deleted lines. */
|
||
|
*** ../vim-7.2.225/src/ex_docmd.c 2009-07-09 15:55:34.000000000 +0200
|
||
|
--- src/ex_docmd.c 2009-07-09 15:24:03.000000000 +0200
|
||
|
***************
|
||
|
*** 7845,7854 ****
|
||
|
if (*ml_get(lnum) == NUL && u_savedel(lnum, 1L) == OK)
|
||
|
{
|
||
|
ml_delete(lnum, FALSE);
|
||
|
- deleted_lines_mark(lnum, 1L);
|
||
|
if (curwin->w_cursor.lnum > 1
|
||
|
&& curwin->w_cursor.lnum >= lnum)
|
||
|
--curwin->w_cursor.lnum;
|
||
|
}
|
||
|
}
|
||
|
redraw_curbuf_later(VALID);
|
||
|
--- 7845,7854 ----
|
||
|
if (*ml_get(lnum) == NUL && u_savedel(lnum, 1L) == OK)
|
||
|
{
|
||
|
ml_delete(lnum, FALSE);
|
||
|
if (curwin->w_cursor.lnum > 1
|
||
|
&& curwin->w_cursor.lnum >= lnum)
|
||
|
--curwin->w_cursor.lnum;
|
||
|
+ deleted_lines_mark(lnum, 1L);
|
||
|
}
|
||
|
}
|
||
|
redraw_curbuf_later(VALID);
|
||
|
*** ../vim-7.2.225/src/if_mzsch.c 2009-06-24 17:51:01.000000000 +0200
|
||
|
--- src/if_mzsch.c 2009-07-09 12:59:17.000000000 +0200
|
||
|
***************
|
||
|
*** 2169,2177 ****
|
||
|
curbuf = savebuf;
|
||
|
raise_vim_exn(_("cannot delete line"));
|
||
|
}
|
||
|
- deleted_lines_mark((linenr_T)n, 1L);
|
||
|
if (buf->buf == curwin->w_buffer)
|
||
|
mz_fix_cursor(n, n + 1, -1);
|
||
|
|
||
|
curbuf = savebuf;
|
||
|
|
||
|
--- 2169,2177 ----
|
||
|
curbuf = savebuf;
|
||
|
raise_vim_exn(_("cannot delete line"));
|
||
|
}
|
||
|
if (buf->buf == curwin->w_buffer)
|
||
|
mz_fix_cursor(n, n + 1, -1);
|
||
|
+ deleted_lines_mark((linenr_T)n, 1L);
|
||
|
|
||
|
curbuf = savebuf;
|
||
|
|
||
|
***************
|
||
|
*** 2299,2307 ****
|
||
|
curbuf = savebuf;
|
||
|
raise_vim_exn(_("cannot delete line"));
|
||
|
}
|
||
|
- deleted_lines_mark((linenr_T)lo, (long)old_len);
|
||
|
if (buf->buf == curwin->w_buffer)
|
||
|
mz_fix_cursor(lo, hi, -old_len);
|
||
|
}
|
||
|
|
||
|
curbuf = savebuf;
|
||
|
--- 2299,2307 ----
|
||
|
curbuf = savebuf;
|
||
|
raise_vim_exn(_("cannot delete line"));
|
||
|
}
|
||
|
if (buf->buf == curwin->w_buffer)
|
||
|
mz_fix_cursor(lo, hi, -old_len);
|
||
|
+ deleted_lines_mark((linenr_T)lo, (long)old_len);
|
||
|
}
|
||
|
|
||
|
curbuf = savebuf;
|
||
|
*** ../vim-7.2.225/src/if_python.c 2009-05-21 23:25:38.000000000 +0200
|
||
|
--- src/if_python.c 2009-07-09 12:59:45.000000000 +0200
|
||
|
***************
|
||
|
*** 2497,2505 ****
|
||
|
PyErr_SetVim(_("cannot delete line"));
|
||
|
else
|
||
|
{
|
||
|
- deleted_lines_mark((linenr_T)n, 1L);
|
||
|
if (buf == curwin->w_buffer)
|
||
|
py_fix_cursor((linenr_T)n, (linenr_T)n + 1, (linenr_T)-1);
|
||
|
}
|
||
|
|
||
|
curbuf = savebuf;
|
||
|
--- 2497,2505 ----
|
||
|
PyErr_SetVim(_("cannot delete line"));
|
||
|
else
|
||
|
{
|
||
|
if (buf == curwin->w_buffer)
|
||
|
py_fix_cursor((linenr_T)n, (linenr_T)n + 1, (linenr_T)-1);
|
||
|
+ deleted_lines_mark((linenr_T)n, 1L);
|
||
|
}
|
||
|
|
||
|
curbuf = savebuf;
|
||
|
***************
|
||
|
*** 2596,2605 ****
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
- deleted_lines_mark((linenr_T)lo, (long)i);
|
||
|
-
|
||
|
if (buf == curwin->w_buffer)
|
||
|
py_fix_cursor((linenr_T)lo, (linenr_T)hi, (linenr_T)-n);
|
||
|
}
|
||
|
|
||
|
curbuf = savebuf;
|
||
|
--- 2596,2604 ----
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
if (buf == curwin->w_buffer)
|
||
|
py_fix_cursor((linenr_T)lo, (linenr_T)hi, (linenr_T)-n);
|
||
|
+ deleted_lines_mark((linenr_T)lo, (long)i);
|
||
|
}
|
||
|
|
||
|
curbuf = savebuf;
|
||
|
*** ../vim-7.2.225/src/if_perl.xs 2009-06-16 16:01:34.000000000 +0200
|
||
|
--- src/if_perl.xs 2009-07-09 13:02:16.000000000 +0200
|
||
|
***************
|
||
|
*** 1233,1241 ****
|
||
|
if (u_savedel(lnum, 1) == OK)
|
||
|
{
|
||
|
ml_delete(lnum, 0);
|
||
|
deleted_lines_mark(lnum, 1L);
|
||
|
- if (aco.save_curbuf == curbuf)
|
||
|
- check_cursor();
|
||
|
}
|
||
|
|
||
|
/* restore curwin/curbuf and a few other things */
|
||
|
--- 1235,1242 ----
|
||
|
if (u_savedel(lnum, 1) == OK)
|
||
|
{
|
||
|
ml_delete(lnum, 0);
|
||
|
+ check_cursor();
|
||
|
deleted_lines_mark(lnum, 1L);
|
||
|
}
|
||
|
|
||
|
/* restore curwin/curbuf and a few other things */
|
||
|
*** ../vim-7.2.225/src/misc1.c 2009-06-24 16:25:23.000000000 +0200
|
||
|
--- src/misc1.c 2009-07-09 13:00:59.000000000 +0200
|
||
|
***************
|
||
|
*** 2345,2356 ****
|
||
|
int undo; /* if TRUE, prepare for undo */
|
||
|
{
|
||
|
long n;
|
||
|
|
||
|
if (nlines <= 0)
|
||
|
return;
|
||
|
|
||
|
/* save the deleted lines for undo */
|
||
|
! if (undo && u_savedel(curwin->w_cursor.lnum, nlines) == FAIL)
|
||
|
return;
|
||
|
|
||
|
for (n = 0; n < nlines; )
|
||
|
--- 2345,2357 ----
|
||
|
int undo; /* if TRUE, prepare for undo */
|
||
|
{
|
||
|
long n;
|
||
|
+ linenr_T first = curwin->w_cursor.lnum;
|
||
|
|
||
|
if (nlines <= 0)
|
||
|
return;
|
||
|
|
||
|
/* save the deleted lines for undo */
|
||
|
! if (undo && u_savedel(first, nlines) == FAIL)
|
||
|
return;
|
||
|
|
||
|
for (n = 0; n < nlines; )
|
||
|
***************
|
||
|
*** 2358,2375 ****
|
||
|
if (curbuf->b_ml.ml_flags & ML_EMPTY) /* nothing to delete */
|
||
|
break;
|
||
|
|
||
|
! ml_delete(curwin->w_cursor.lnum, TRUE);
|
||
|
++n;
|
||
|
|
||
|
/* If we delete the last line in the file, stop */
|
||
|
! if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
|
||
|
break;
|
||
|
}
|
||
|
- /* adjust marks, mark the buffer as changed and prepare for displaying */
|
||
|
- deleted_lines_mark(curwin->w_cursor.lnum, n);
|
||
|
|
||
|
curwin->w_cursor.col = 0;
|
||
|
check_cursor_lnum();
|
||
|
}
|
||
|
|
||
|
int
|
||
|
--- 2359,2379 ----
|
||
|
if (curbuf->b_ml.ml_flags & ML_EMPTY) /* nothing to delete */
|
||
|
break;
|
||
|
|
||
|
! ml_delete(first, TRUE);
|
||
|
++n;
|
||
|
|
||
|
/* If we delete the last line in the file, stop */
|
||
|
! if (first > curbuf->b_ml.ml_line_count)
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
+ /* Correct the cursor position before calling deleted_lines_mark(), it may
|
||
|
+ * trigger a callback to display the cursor. */
|
||
|
curwin->w_cursor.col = 0;
|
||
|
check_cursor_lnum();
|
||
|
+
|
||
|
+ /* adjust marks, mark the buffer as changed and prepare for displaying */
|
||
|
+ deleted_lines_mark(first, n);
|
||
|
}
|
||
|
|
||
|
int
|
||
|
***************
|
||
|
*** 2621,2626 ****
|
||
|
--- 2625,2632 ----
|
||
|
|
||
|
/*
|
||
|
* Like deleted_lines(), but adjust marks first.
|
||
|
+ * Make sure the cursor is on a valid line before calling, a GUI callback may
|
||
|
+ * be triggered to display the cursor.
|
||
|
*/
|
||
|
void
|
||
|
deleted_lines_mark(lnum, count)
|
||
|
*** ../vim-7.2.225/src/version.c 2009-07-09 18:24:24.000000000 +0200
|
||
|
--- src/version.c 2009-07-09 20:01:16.000000000 +0200
|
||
|
***************
|
||
|
*** 678,679 ****
|
||
|
--- 678,681 ----
|
||
|
{ /* Add new patch number below this line */
|
||
|
+ /**/
|
||
|
+ 226,
|
||
|
/**/
|
||
|
|
||
|
--
|
||
|
hundred-and-one symptoms of being an internet addict:
|
||
|
80. At parties, you introduce your spouse as your "service provider."
|
||
|
|
||
|
/// 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 ///
|