eclipse-multicursor icon indicating copy to clipboard operation
eclipse-multicursor copied to clipboard

Undo (ctrl+z) makes a mess

Open sylviatancheva opened this issue 11 years ago • 5 comments

While editing a few lines I pressed ctrl+z few times and all the code went into a huge mess. Seems that undo is buggy. (Eclipse Version: 4.4.0.v20140925-0400)

sylviatancheva avatar Oct 09 '14 11:10 sylviatancheva

Ah, that makes sense; I'm not suspending undo at all, which I think other invocations of linked mode editing do.

Thank you for the bug report.

caspark avatar Oct 09 '14 11:10 caspark

@sylviatancheva / @mniewrzal (since you opened #18 and #21 so presumably you've had this problem), are either of you able to provide a consistent set of steps which will lead to things getting into a huge mess?

I tried to reproduce this by selecting all or some occurrences of the text MyThing in the snippet

public class SomeMyThing {
    public void MyThing() {
        MyThing();
        // MyThing();
        System.out.println("MyThing; yep, MyThing");
        /*And sometimes I like MyThing*/
    }
}

but the behaviour I got was pretty reasonable:

  • While editing, hitting undo once will undo a batch of changes across all portions of text being edited.
  • After editing, hitting undo once will undo a change in a single portion of text that was edited. It'd be nice if it kept the same behaviour as during editing, but I don't think this is a big issue (just hold down ctrl+z).

caspark avatar Nov 09 '14 07:11 caspark

I used a very simple php example:

sylviatancheva avatar Nov 09 '14 08:11 sylviatancheva

@caspark perhaps the issue is more visible on those editor which are based on WTP Source Editing. Try editors like HTML, XML, CSS and PHP.

kaloyan-raev avatar Nov 09 '14 12:11 kaloyan-raev

Thanks, confirmed on the PHP editor; I can get some very screwy things to happen.

Experimenting a bit, I determined that this only happens when you already have some undo history; for example, when I created a php file with the contents echo 1 echo 2, close it (to lose the undo history), reopen it, and start renaming echo to echoq, then ctrl+z doesn't do anything.

But it's also deterministic: if, after freshly opening the file with contents echo 1 echo 2, I change the text to echo 1 echo 2z and start renaming echo to echoq, then when I hit ctrl+z then the text consistently changes to echo1 echo 2z.

Anyway, disabling undo while in linked edit mode is probably the easiest hack to work around this. (I don't think it's really worth investigating how to fix it properly, because any "real" multiple cursor support will need to move away from linked mode editing anyway.)

caspark avatar Nov 10 '14 12:11 caspark