Broken undo?

Showing 1-10 of 11 messages
Broken undo? Israel Chauca F. 5/13/10 12:38 AM
Hi there,

I found the following, open vim and do the following:

- Insert 1 and exit insert mode.
- Append 2 and then <C-R>=setline('.', '123')<CR> to add one char to the right of the cursor.
- Without leaving insert mode, type other <CR> and the number 4, now exit insert mode.
- Press u.

I should expect to have just the number 1 in the window, but I'm left with two lines:

1
43

If I undo again, I get the original empty window.

If I start in the second step, I can't undo to the empty window, I'm left with two lines but I can exit vim as if the buffer was in its original state.

Is that the expected behaviour or there is something wrong? why does the setline() call + <CR> affects the first edit?

Thanks!
Israel




--
You received this message from the "vim_use" 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
Re: Broken undo? Tony Mechelynck 5/13/10 2:14 AM
On 13/05/10 09:38, Israel Chauca F. wrote:
> Hi there,
>
> I found the following, open vim and do the following:
>
> - Insert 1 and exit insert mode.
> - Append 2 and then<C-R>=setline('.', '123')<CR>  to add one char to the right of the cursor.
> - Without leaving insert mode, type other<CR>  and the number 4, now exit insert mode.
> - Press u.
>
> I should expect to have just the number 1 in the window, but I'm left with two lines:
>
> 1
> 43
>
> If I undo again, I get the original empty window.
>
> If I start in the second step, I can't undo to the empty window, I'm left with two lines but I can exit vim as if the buffer was in its original state.
>
> Is that the expected behaviour or there is something wrong? why does the setline() call +<CR>  affects the first edit?
>
> Thanks!
> Israel
>
>
>
>

In 'compatible' mode (including, by default, when you start Vim with no
vimrc, or with the -u command-line switch in order to use a nonstandard
vimrc), repeatedly hitting u alternates between the two latest states of
the buffer (this is vi-compatible "undoable undo").

In 'nocompatible' mode, including when Vim has found a .vimrc or a
_vimrc, repeatedly hitting u goes progressively backwards in time, up to
'undolevels' times. In that case, CTRL-R (in Normal mode) redoes what
had been undone.

See
        :help 'undolevels'
        :help undo-two-ways


Best regards,
Tony.
--
Cold, adj.:
        When the politicians walk around with their hands in their own
pockets.
Re: Broken undo? Christian Brabandt 5/13/10 2:49 AM
Hi Israel!

On Do, 13 Mai 2010, Israel Chauca F. wrote:

> Hi there,
>
> I found the following, open vim and do the following:
>
> - Insert 1 and exit insert mode.
> - Append 2 and then <C-R>=setline('.', '123')<CR> to add one char to the right of the cursor.
> - Without leaving insert mode, type other <CR> and the number 4, now exit insert mode.
> - Press u.
>
> I should expect to have just the number 1 in the window, but I'm left with two lines:
>
> 1
> 43

I can reproduce it. That looks like a bug to me

> If I undo again, I get the original empty window.
>
> If I start in the second step, I can't undo to the empty window, I'm left with two lines but I can exit vim as if the buffer was in its original state.
>

I can't reproduce that.

> Is that the expected behaviour or there is something wrong? why does the setline() call + <CR> affects the first edit?

It shouldn't I guess. Report it to Bram

regards,
Christian
Re: Broken undo? Bram Moolenaar 5/13/10 4:12 AM

Israel Chauca wrote:

> I found the following, open vim and do the following:
>
> - Insert 1 and exit insert mode.
> - Append 2 and then <C-R>=setline('.', '123')<CR> to add one char to
>   the right of the cursor.
> - Without leaving insert mode, type other <CR> and the number 4, now
> exit insert mode.
> - Press u.
>
> I should expect to have just the number 1 in the window, but I'm left
> with two lines:
>
> 1
> 43

That indeed looks like a bug.

> If I undo again, I get the original empty window.
>
> If I start in the second step, I can't undo to the empty window, I'm
> left with two lines but I can exit vim as if the buffer was in its
> original state.

I don't see this problem.

> Is that the expected behaviour or there is something wrong? why does
> the setline() call + <CR> affects the first edit?

A whole insert should be one undo step.  But when you invoke setline()
this is messed up.  Evaluating the expression was not supposed the side
effect of changing the text.

--
"You know, it's at times like this when I'm trapped in a Vogon airlock with
a man from Betelgeuse and about to die of asphyxiation in deep space that I
really wish I'd listened to what my mother told me when I was young!"
"Why, what did she tell you?"
"I don't know, I didn't listen!"
                -- Arthur Dent and Ford Prefect in Douglas Adams'
                   "The Hitchhiker's Guide to the Galaxy"

 /// 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    ///
Re: Broken undo? Israel Chauca F. 5/13/10 12:31 PM
On May 13, 2010, at 6:12 AM, Bram Moolenaar wrote:
>
>
> Israel Chauca wrote:
>
>> I found the following, open vim and do the following:
>>
>> - Insert 1 and exit insert mode.
>> - Append 2 and then <C-R>=setline('.', '123')<CR> to add one char to
>>  the right of the cursor.
>> - Without leaving insert mode, type other <CR> and the number 4, now
>> exit insert mode.
>> - Press u.
>>
>> I should expect to have just the number 1 in the window, but I'm left
>> with two lines:
>>
>> 1
>> 43
>
> That indeed looks like a bug.

Good to know. Should I write a ticket for this bug somewhere or do something else?

>
>> If I undo again, I get the original empty window.
>>
>> If I start in the second step, I can't undo to the empty window, I'm
>> left with two lines but I can exit vim as if the buffer was in its
>> original state.
>
> I don't see this problem.

I can reproduce it in the default vim for MacOS X 10.6 and MacVim, but neither of them are the latest version, when I can compile vim in my Mac I'll try again.

Thanks!
Israel
Re: Broken undo? Bram Moolenaar 5/13/10 1:56 PM

Israel Chauca wrote:


> >> I found the following, open vim and do the following:
> >>
> >> - Insert 1 and exit insert mode.
> >> - Append 2 and then <C-R>=setline('.', '123')<CR> to add one char to
> >>  the right of the cursor.
> >> - Without leaving insert mode, type other <CR> and the number 4, now
> >> exit insert mode.
> >> - Press u.
> >>
> >> I should expect to have just the number 1 in the window, but I'm left
> >> with two lines:
> >>
> >> 1
> >> 43
> >
> > That indeed looks like a bug.
>
> Good to know. Should I write a ticket for this bug somewhere or do
> something else?

No need.  Storing bugs in a dusty database won't help getting them
solved.

> >> If I undo again, I get the original empty window.
> >>
> >> If I start in the second step, I can't undo to the empty window, I'm
> >> left with two lines but I can exit vim as if the buffer was in its
> >> original state.
> >
> > I don't see this problem.
>
> I can reproduce it in the default vim for MacOS X 10.6 and MacVim, but
> neither of them are the latest version, when I can compile vim in my
> Mac I'll try again.

Perhaps you need to explain more cleary what you do exactly.

--
To define recursion, we must first define recursion.

 /// 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    ///

Re: Broken undo? Israel Chauca F. 5/13/10 2:43 PM
On May 13, 2010, at 3:56 PM, Bram Moolenaar wrote:
>
>
>>> That indeed looks like a bug.
>>
>> Good to know. Should I write a ticket for this bug somewhere or do
>> something else?
>
> No need.  Storing bugs in a dusty database won't help getting them
> solved.

Noted.

>>>> If I undo again, I get the original empty window.
>>>>
>>>> If I start in the second step, I can't undo to the empty window, I'm
>>>> left with two lines but I can exit vim as if the buffer was in its
>>>> original state.
>>>
>>> I don't see this problem.
>>
>> I can reproduce it in the default vim for MacOS X 10.6 and MacVim, but
>> neither of them are the latest version, when I can compile vim in my
>> Mac I'll try again.
>
> Perhaps you need to explain more cleary what you do exactly.

The next steps are are just one insert:
1. Insert 1.
2. Now <C-R>=setline('.','12')<CR>
3. Insert <CR>
4. Exit insert mode and undo (u).

The buffer should be empty but it has two lines, the first one is empty and the second one has the number 2 in it. Since the buffer isn't empty, I should get E37 when I :quit, instead vim exits without any message.

Let's see if that works.

Thanks,
Israel
Re: Broken undo? Bram Moolenaar 5/14/10 2:44 AM
I see it.  It's the same problem as the first one in a different form.

--
hundred-and-one symptoms of being an internet addict:
34. You laugh at people with 14400 baud modems.

 /// 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    ///

Re: Broken undo? Bram Moolenaar 4/21/13 4:07 AM

Israel Chauca wrote:

> Hello,
> I see this thread is a bit old (and that no bug was filed :P) but was
> wondering:
>  - did this ever get resolved?
>  - or, is there a workaround?
>
> For me the issue arises in usage of the delimitMate plugin (related
> bug: https://github.com/Raimondi/delimitMate/issues/114 )

The issue is still in the todo list.  That list is rather long...

--
hundred-and-one symptoms of being an internet addict:
200. You really believe in the concept of a "paperless" office.

 /// Bram Moolenaar -- Bram@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        ///
Re: Broken undo? Christian Brabandt 4/21/13 5:16 AM
Hi Mime!

On Sa, 20 Apr 2013, Mime Čuvalo wrote:

> Hello,
> I see this thread is a bit old (and that no bug was filed :P) but was wondering:
>  - did this ever get resolved?
>  - or, is there a workaround?
>
> For me the issue arises in usage of the delimitMate plugin (related bug: https://github.com/Raimondi/delimitMate/issues/114 )

Can you check, if this patch fixes it for you?
https://groups.google.com/d/msg/vim_use/Rw637BtyIWs/WSWPdp4jW2oJ

Mit freundlichen Grüßen
Christian
--
Wenn der Kernel keinen Treiber für das ATAPI-CDROM hat,
wie soll er dann dafür eine SCSI-Emulation machen?
Merke: erst denken, dann posten.
                -- Felix von Leitner