Iruyan-Zak / vim

Automatically exported from code.google.com/p/vim
0 stars 0 forks source link

Undo can leave buffer in a never before seen state after a multi-line edit. #324

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

While somewhat elaborate, this should produce it every time.

(You need to set nocompatible and backspace=2 to edit text like this in insert 
mode. This is the default for the Arch Linux package.)

Open new buffer, insert two rows:
foo bar
bar foo

Enter insert mode on the first row with the cursor over 'b'.
1) use backspace to delete a character
2) use arrow keys to move one down, and three to the left
3) press backspace three times

The buffer sould now look like this:
foobbar foo

Leave insert mode and press u once.

What is the expected output? What do you see instead?

Expected buffer contents:
foo bar
bar foo

Buffer contents instead:
foobbar foo
bar foo

This is not a state the buffer has, from the perspective of the user, ever been 
in during editing. It looks like an internal meta-state where the lines have 
been concatenated, but the original line has not yet been deleted.

What version of the product are you using? On what operating system?

vim 7.4.580 from Arch Linux package gvim (for x clipboard support).

Please provide any additional information below.

The bug is introduced by Changeset 5852 (v. 7.4.269)

Please note that the reproduction instructions have some unnecessary steps. For 
example, the problem can be reproduced by just pressing backspace once in step 
3 to concatenate the lines.

However, some similar sequences that do not produce the problem:
- Following instructions without step 1.
- Following instructions, but substituting any left arrow key press with a 
backspace during step 2.
- Using the Delete key at the end of the first row to combine the rows instead 
of using backspace at the beginning of the second.

Original issue reported on code.google.com by paoe...@gmail.com on 28 Jan 2015 at 4:44

GoogleCodeExporter commented 9 years ago
Here is a patch.
I even added a test, but unfortunately, undo works slightly different when 
input comes from a script file which means, when running the test suite, the 
test would always succeed ;(
So I skip that for now. 

Original comment by chrisbr...@googlemail.com on 28 Jan 2015 at 9:57

Attachments:

GoogleCodeExporter commented 9 years ago
Quick work! I can confirm the patch fixes the issue described. Shame if undo in 
general is problematic to test automatically though, since it's hard to be 
assured nothing else breaks with changes.

Original comment by paoe...@gmail.com on 29 Jan 2015 at 9:05

GoogleCodeExporter commented 9 years ago
Fix included by patch 7.4.640

Original comment by brammool...@gmail.com on 17 Feb 2015 at 4:57