Hi Андрей!
On Di, 14 Feb 2012, Андрей Радев wrote:
> Hello,
>
> I've encountered some odd behaviour with Vim. I have a file containing
> the following text:
>
> one = {
> two: {
> three: four;
> }
> }
> // Some text here;
>
> I do the following:
>
> 1. Go to the first "t" in "three: four;", mark the line in
> character-wise visual mode (with "v$") and then yank it.
> 2. Press "Va{" to mark the curly brackets.
> 3. Paste
>
> The result looks like this:
>
> one = {
> two: three: four;
> }
> // Some text here;
>
> However, if the "Some text" line is not present, so that the "}" is on
> the last line of the file, the result is this:
>
> one = {
> two: three: four;}
>
> If I perform an undo with "u", it turns into this:
>
> one = {
> two: {
> three: four;
> }
> two: }
>
> The file is marked as unmodified, and quitting Vim leaves it exactly
> as if the undo worked correctly. However, saving the file results in
> this text being saved to disk.
Looks familiar¹ and seems to be another regression from patch 7.3.251.
However, I think, this patch fixes it:
diff --git a/src/ops.c b/src/ops.c
--- a/src/ops.c
+++ b/src/ops.c
@@ -1943,12 +1943,14 @@
else /* delete characters between lines */
{
pos_T curpos;
+ int delete_last_line;
/* save deleted and changed lines for undo */
if (u_save((linenr_T)(curwin->w_cursor.lnum - 1),
(linenr_T)(curwin->w_cursor.lnum + oap->line_count)) == FAIL)
return FAIL;
+ delete_last_line = (oap->end.lnum == curbuf->b_ml.ml_line_count);
truncate_line(TRUE); /* delete from cursor to end of line */
curpos = curwin->w_cursor; /* remember curwin->w_cursor */
@@ -1956,8 +1958,8 @@
del_lines((long)(oap->line_count - 2), FALSE);
n = (oap->end.col + 1 - !oap->inclusive);
- if (oap->inclusive && oap->end.lnum == curbuf->b_ml.ml_line_count
- && n > (int)STRLEN(ml_get(oap->end.lnum)))
+ if (oap->inclusive && delete_last_line
+ && n > (int)STRLEN(ml_get(oap->end.lnum)) && FALSE)
{
/* Special case: gH<Del> deletes the last line. */
del_lines(1L, FALSE);
¹)http://groups.google.com/group/vim_dev/msg/5d7f2809b0fc5d61
regards,
Christian
--
Von einem bedeutenden frauenzimmerlichen Gedichte sagte jemand,
es habe mehr Energie als Enthusiasmus, mehr Charakter als Gehalt,
mehr Rhetorik als Poesie und im ganzen etwas Männliches.
-- Goethe, Maximen und Reflektionen, Nr. 502
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php