[vim/vim] 'virtualedit' and tabulation affect number increment/decrement (#923)

94 views
Skip to first unread message

xaizek

unread,
Jul 14, 2016, 1:30:56 PM7/14/16
to vim/vim

Run Vim like this:

vim -N -u NONE -c 'set virtualedit=all'

Enter the following text:

<tabulation>1

See how cursor position relative to tabulation affects placement of incremented/decremented number:

" "|" designates cursor position
|       1
" <ctrl-x> gives this (OK)
|       0
" moving cursor to the right before pressing <ctrl-x> moves number (not OK)
 |       -1
  |       -2
   |       -3
" etc.

Virtual space seems to be counted as if it was a real character.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, .

h_east

unread,
Jul 15, 2016, 11:17:14 AM7/15/16
to vim_dev, v...@noreply.github.com, reply+00b1d1988a9211c22d22ff6b500caab193bdd2f...@reply.github.com, vim-dev...@256bit.org
Hi xaizek and list,

2016-7-15(Fri) 2:30:56 UTC+9 xaizek:
I can reproduce your reported issue.

And I also found a bug that involved to increment/decrement with vitrual edit.

How to reproduce:
- Start naked Vim with virtualedit.
$ vim -Nu NONE -c "set ve=all"

- Input buffer to `3`
i3<Esc>

- Cursor move to the right edge.
g$

- Do increment.
<C-A>


Expected result:
- Buffer is not changed.


Actual result:
- Number was incremented and move to before the right edge.


I'll investigate these issues on this weekend or next.
I have wrote some patches involved to CTRL-A and CTRL-X.
e.g.
https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e

Thanks.
--
Best regards,
Hirohito Higashi (a.k.a. h_east)

vim-dev ML

unread,
Jul 15, 2016, 11:17:45 AM7/15/16
to vim/vim, vim-dev ML, Your activity
Hi xaizek and list,

2016-7-15(Fri) 2:30:56 UTC+9 xaizek:
I can reproduce your reported issue.

And I also found a bug that involved to increment/decrement with vitrual edit.

How to reproduce:
- Start naked Vim with virtualedit.
$ vim -Nu NONE -c "set ve=all"

- Input buffer to `3`
i3<Esc>

- Cursor move to the right edge.
g$

- Do increment.
<C-A>


Expected result:
- Buffer is not changed.


Actual result:
- Number was incremented and move to before the right edge.


I'll investigate these issues on this weekend or next.
I have wrote some patches involved to CTRL-A and CTRL-X.
e.g.
https://github.com/vim/vim/commit/d79e55016cf8268cee935f1ac3b5b28712d1399e

Thanks.
--
Best regards,
Hirohito Higashi (a.k.a. h_east)


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub, or mute the thread.

vim-dev ML

unread,
Jul 15, 2016, 1:08:47 PM7/15/16
to vim/vim, vim-dev ML, Your activity
On Fr, 15 Jul 2016, h_east wrote:

> Hi xaizek and list,
>
> 2016-7-15(Fri) 2:30:56 UTC+9 xaizek:
> I can reproduce your reported issue.

Yeah, the problem is, that ins_str() changes the buffer and actually
inserts blanks, if the cursor is beyond the line end.

I tried this patch:
```diff
--- a/src/ops.c
+++ b/src/ops.c
@@ -5835,7 +5835,18 @@ do_addsub(
*ptr++ = '0';
*ptr = NUL;
STRCAT(buf1, buf2);
+#ifdef FEAT_VIRTUALEDIT
+ if (virtual_active())
+ {
+ save_cursor = curwin->w_cursor;
+ curwin->w_cursor.coladd = 0;
+ }
+#endif
ins_str(buf1); /* insert the new number */
+#ifdef FEAT_VIRTUALEDIT
+ if (virtual_active())
+ curwin->w_cursor.coladd = save_cursor.coladd;
+#endif
vim_free(buf1);
endpos = curwin->w_cursor;
if (did_change && curwin->w_cursor.col)
```
this almost works, except that after incrementing/decrementing ml_get()
still returns the wrong line. I don't know why yet.

On the other hand, one could argue, that the number shouldn't be
incremented/decremented at all if the cursor is actually not on a
number, so you could even consider the successful increment to be a bug.

I don't know.


Best,
Christian
--
Radio:
in manchen Kreisen wurden mit Radios umfangreiche Berechnungen
angestellt


You are receiving this because you are subscribed to this thread.

h_east

unread,
Aug 1, 2016, 11:06:39 AM8/1/16
to vim_dev, v...@noreply.github.com, vim-dev...@256bit.org, your_a...@noreply.github.com, reply+00b1d198406060b8b7726691cef47d6c07eab15...@reply.github.com
Hi xaizek, ChrisB and Bram,

2016-7-16(Sat) 2:08:47 UTC+9 vim-dev ML:
ChrisB>
Your patch is a good hint for me. Thanks!

I wrote a patch with a test.
Please check and include this.
fix_increment_with_virtualedit.patch

vim-dev ML

unread,
Aug 1, 2016, 11:07:09 AM8/1/16
to vim/vim, vim-dev ML, Your activity
Hi xaizek, ChrisB and Bram,

2016-7-16(Sat) 2:08:47 UTC+9 vim-dev ML:
> On Fr, 15 Jul 2016, h_east wrote:
>
>
>
> > Hi xaizek and list,
>
> >
>
> > 2016-7-15(Fri) 2:30:56 UTC+9 xaizek:
>


You are receiving this because you are subscribed to this thread.

Bram Moolenaar

unread,
Aug 1, 2016, 11:21:40 AM8/1/16
to h_east, vim_dev, v...@noreply.github.com, vim-dev...@256bit.org, your_a...@noreply.github.com, reply+00b1d198406060b8b7726691cef47d6c07eab15...@reply.github.com

Hirohito Higashi wrote:

[...]

> > this almost works, except that after incrementing/decrementing ml_get()
> > still returns the wrong line. I don't know why yet.
> >
> > On the other hand, one could argue, that the number shouldn't be
> > incremented/decremented at all if the cursor is actually not on a
> > number, so you could even consider the successful increment to be a bug.
>
> ChrisB>
> Your patch is a good hint for me. Thanks!
>
> I wrote a patch with a test.
> Please check and include this.

Thanks!

--
God made machine language; all the rest is the work of man.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

vim-dev ML

unread,
Aug 1, 2016, 11:22:12 AM8/1/16
to vim/vim, vim-dev ML, Your activity

h_east

unread,
Mar 28, 2018, 11:00:22 AM3/28/18
to vim_dev
Hi Bram,

2016-8-2(Tue) 0:21:40 UTC+9 Bram Moolenaar:


> Hirohito Higashi wrote:
>
> [...]
>
> > > this almost works, except that after incrementing/decrementing ml_get()
> > > still returns the wrong line. I don't know why yet.
> > >
> > > On the other hand, one could argue, that the number shouldn't be
> > > incremented/decremented at all if the cursor is actually not on a
> > > number, so you could even consider the successful increment to be a bug.
> >
> > ChrisB>
> > Your patch is a good hint for me. Thanks!
> >
> > I wrote a patch with a test.
> > Please check and include this.
>
> Thanks!

This issue is in the todo list yet.

> Patch to fix increment/decrement not working properly when 'virtualedit' is
> set. (Hirohito Higashi, 2016 Aug 1, #923)

You said "Thanks!" a year and a half ago.
Perhaps you forgot to include my patch? :-)

I attached the updated patch.
Thank you for your consideration.
--
Best regards,
Hirohito Higashi (h_east)

fix_increment_with_virtualedit.patch

Bram Moolenaar

unread,
Mar 28, 2018, 4:18:44 PM3/28/18
to vim...@googlegroups.com, h_east
Sorry, sometimes I'm busy and unable to keep up with patches. And then
later don't manage to work away the backlog, resulting in some things
slipping down in the todo list. I'll move this one further up.

--
hundred-and-one symptoms of being an internet addict:
83. Batteries in the TV remote now last for months.

Bram Moolenaar

unread,
Jun 10, 2020, 5:10:18 PM6/10/20
to vim/vim, vim-dev ML, Comment

Was this fixed? There is mention of a fix, thus I suspect it was fixed.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.

xaizek

unread,
Jun 10, 2020, 7:01:05 PM6/10/20
to vim/vim, vim-dev ML, Comment

Just checked on Vim 8.2.909, the bug is still there. I guess the patch wasn't applied.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.

Christian Brabandt

unread,
Jun 11, 2020, 2:55:42 AM6/11/20
to vim/vim, vim-dev ML, Comment

The patch is here: https://groups.google.com/d/msg/vim_dev/eCtwsQw0f7I/Of_20pacBgAJ

Can you try to apply it and see if this works? It also contains a test to fix this.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.

xaizek

unread,
Jun 11, 2020, 10:37:36 AM6/11/20
to vim/vim, vim-dev ML, Comment

It doesn't work and the test fails. Here is the patch updated to cleanly apply on 2d4070d: fix_increment_with_virtualedit_updated.txt (github doesn't like .patch extension...).


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.

Christian Brabandt

unread,
Jun 11, 2020, 1:57:57 PM6/11/20
to vim/vim, vim-dev ML, Comment

fix_increment_with_virtualedit_updated.txt (github doesn't like .patch extension...).

That file contains ANSI escape sequences and I could not apply it. I have a suspicion, that the problem is the #ifdef FEAT_VIRTUALEDIT. That feature has been graduated to be always included as of 8.1.826, so I suspect the patch is actually not really included.

I'll applied it locally, and the test seems to pass and also the original bug report at the top also seems to be fixed. Please check, PR coming in just a minute. I also notice the help mentions, not available when compiled without the |+virtualedit| feature, so I also updated the help documents slightly.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.

xaizek

unread,
Jun 11, 2020, 4:10:36 PM6/11/20
to vim/vim, vim-dev ML, Comment

Sorry, I don't know why git uses external diff even when output is redirected. I tested your branch and can confirm that it fixes the issue and the new test passes.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.

Christian Brabandt

unread,
Jun 11, 2020, 4:23:47 PM6/11/20
to vim/vim, vim-dev ML, Comment

Sorry, I don't know why git uses external diff even

you might need --no-ext-diff argument for git.

thanks for confirming it works.! 👍


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.

xaizek

unread,
Jun 11, 2020, 4:48:21 PM6/11/20
to vim/vim, vim-dev ML, Comment

you might need --no-ext-diff argument for git.

I need it to stop using external diff with redirection precisely because I forget about adding --no-ext-diff :)

Thanks for the fix.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.

Bram Moolenaar

unread,
Jun 12, 2020, 2:20:12 PM6/12/20
to vim/vim, vim-dev ML, Comment

Closed #923 via 6c6be9e.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.

lacygoill

unread,
Jan 27, 2021, 12:28:06 PM1/27/21
to vim/vim, vim-dev ML, Comment

Since the issue was fixed, then this todo item is no longer relevant:

https://github.com/vim/vim/blob/21829c5f2c86cd525c8468121b4fc54c5d75bf6e/runtime/doc/todo.txt#L1136-L1138

As for the question:

Was this fixed?

Yes, it was. I can't reproduce on master.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.

Reply all
Reply to author
Forward
0 new messages