Hi Bram!
On Do, 05 Jan 2012, Bram Moolenaar wrote:
>
> Christian Brabandt wrote:
>
> > I found another problem that was introduced with 7.3.251.
> >
> > vim -u NONE -U NONE -N -i NONE -c "call setline('.',
> > ['','foobar',''])|$"
> >
> > Now the cursor is on the last line. Execute this command:
> > dv?bar
> >
> > First, notice, that the buffer now looks like this:
> >
> > -----
> > foo
> > -----
> >
> > e.g. the first line was wrongly deleted. Now if you undo the previous
> > command (press u), you see this:
> >
> > ----
> > foo
> > foobar
> >
> > ----
> >
> > So the undo did not work correctly.
> >
> > I did a hg bisect to find the patch, that introduced this regression and
> > according to my testings, it was introduced with patch 7.3.251:
> >
> > ,----
> > | Änderung: 2957:fe6ad3fd8532
> > | Marke: v7-3-251
> > | Nutzer: Bram Moolenaar <[email protected]>
> > | Datum: Fri Jul 15 17:51:34 2011 +0200
> > | Dateien: src/normal.c src/ops.c src/version.c
> > | Beschreibung:
> > | updated for version 7.3.251
> > | Problem: "gH<Del>" deletes the current line, except when it's the last
> > | line.
> > | Solution: Set the "include" flag to indicate the last line is to be
> > | deleted.
> > `----
> >
> > I am not sure if there are actually two problems (wrong undo and
> > wrongly joined lines) or if this is just the same problem. However, the
> > following patch fixes the wrongly joining lines for me and the wrong
> > undo does not occur anymore:
> >
> > diff --git a/src/ops.c b/src/ops.c
> > --- a/src/ops.c
> > +++ b/src/ops.c
> > @@ -1961,7 +1961,8 @@
> > /* Special case: gH<Del> deletes the last line. */
> > del_lines(1L, FALSE);
> > curwin->w_cursor = curpos; /* restore curwin->w_cursor
> > */
> > - if (curwin->w_cursor.lnum > 1)
> > + if (curwin->w_cursor.lnum > 1 &&
> > + curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
> > --curwin->w_cursor.lnum;
> > }
> > else
>
> Thanks for finding out what is wrong and the suggested patch.
> I'll check later if this is the best solution.
>
> And to prevent further regressions a test would be nice.
Good idea. See attachment.
regards,
Christian
--
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
diff --git a/src/ops.c b/src/ops.c
--- a/src/ops.c
+++ b/src/ops.c
@@ -1961,7 +1961,8 @@
/* Special case: gH<Del> deletes the last line. */
del_lines(1L, FALSE);
curwin->w_cursor = curpos; /* restore curwin->w_cursor */
- if (curwin->w_cursor.lnum > 1)
+ if (curwin->w_cursor.lnum > 1 &&
+ curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
--curwin->w_cursor.lnum;
}
else
diff --git a/src/testdir/test43.in b/src/testdir/test43.in
--- a/src/testdir/test43.in
+++ b/src/testdir/test43.in
@@ -13,7 +13,9 @@
x:set magic
/\v(a)(b)\2\1\1/e
x/\V[ab]\(\[xy]\)\1
-x:?^1?,$w! test.out
+x:$
+dv?bar?
+:?^1?,$w! test.out
:qa!
ENDTEST
@@ -25,3 +27,5 @@
6 x ^aa$ x
7 (a)(b) abbaa
8 axx [ab]xx
+9 foobar
+
diff --git a/src/testdir/test43.ok b/src/testdir/test43.ok
--- a/src/testdir/test43.ok
+++ b/src/testdir/test43.ok
@@ -6,3 +6,4 @@
6 x aa$ x
7 (a)(b) abba
8 axx ab]xx
+9 foo