mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
Compound edits weren't part of the undo/redo dance
This commit is contained in:
@ -1693,10 +1693,11 @@ public class Editor extends JFrame implements RunnerListener {
|
|||||||
document.addUndoableEditListener(new UndoableEditListener() {
|
document.addUndoableEditListener(new UndoableEditListener() {
|
||||||
public void undoableEditHappened(UndoableEditEvent e) {
|
public void undoableEditHappened(UndoableEditEvent e) {
|
||||||
if (compoundEdit != null) {
|
if (compoundEdit != null) {
|
||||||
compoundEdit.addEdit(e.getEdit());
|
compoundEdit.addEdit(new CaretAwareUndoableEdit(e.getEdit(), textarea));
|
||||||
|
|
||||||
} else if (undo != null) {
|
} else if (undo != null) {
|
||||||
undo.addEdit(new CaretAwareUndoableEdit(e.getEdit(), textarea));
|
undo.addEdit(new CaretAwareUndoableEdit(e.getEdit(), textarea));
|
||||||
|
}
|
||||||
|
if (compoundEdit != null || undo != null) {
|
||||||
sketch.setModified(true);
|
sketch.setModified(true);
|
||||||
undoAction.updateUndoState();
|
undoAction.updateUndoState();
|
||||||
redoAction.updateRedoState();
|
redoAction.updateRedoState();
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
package processing.app;
|
||||||
|
|
||||||
|
import org.fest.swing.edt.GuiActionRunner;
|
||||||
|
import org.fest.swing.edt.GuiQuery;
|
||||||
|
import org.fest.swing.fixture.JMenuItemFixture;
|
||||||
|
import org.junit.Test;
|
||||||
|
import processing.app.helpers.JEditTextAreaFixture;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
public class BlockCommentGeneratesOneUndoActionTest extends AbstractGUITest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldUndoAndRedo() throws Exception {
|
||||||
|
JMenuItemFixture menuEditUndo = window.menuItem("menuEditUndo");
|
||||||
|
menuEditUndo.requireDisabled();
|
||||||
|
|
||||||
|
JEditTextAreaFixture jEditTextArea = window.jEditTextArea("editor");
|
||||||
|
String previousText = jEditTextArea.getText();
|
||||||
|
|
||||||
|
jEditTextArea.selectAll();
|
||||||
|
|
||||||
|
GuiActionRunner.execute(new GuiQuery<Frame>() {
|
||||||
|
|
||||||
|
protected Frame executeInEDT() {
|
||||||
|
window.getEditor().handleCommentUncomment();
|
||||||
|
return window.getEditor();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
menuEditUndo.requireEnabled();
|
||||||
|
menuEditUndo.click();
|
||||||
|
|
||||||
|
assertEquals(previousText, jEditTextArea.getText());
|
||||||
|
|
||||||
|
menuEditUndo.requireDisabled();
|
||||||
|
}
|
||||||
|
}
|
@ -1,30 +1,23 @@
|
|||||||
package processing.app.helpers;
|
package processing.app.helpers;
|
||||||
|
|
||||||
import org.fest.swing.core.Robot;
|
|
||||||
import org.fest.swing.fixture.FrameFixture;
|
import org.fest.swing.fixture.FrameFixture;
|
||||||
|
import processing.app.Editor;
|
||||||
import processing.app.syntax.JEditTextArea;
|
import processing.app.syntax.JEditTextArea;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
public class ArduinoFrameFixture extends FrameFixture {
|
public class ArduinoFrameFixture extends FrameFixture {
|
||||||
|
|
||||||
public ArduinoFrameFixture(Frame target) {
|
private final Editor editor;
|
||||||
super(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArduinoFrameFixture(org.fest.swing.core.Robot robot, Frame target) {
|
public ArduinoFrameFixture(Editor editor) {
|
||||||
super(robot, target);
|
super(editor);
|
||||||
}
|
this.editor = editor;
|
||||||
|
|
||||||
public ArduinoFrameFixture(Robot robot, String name) {
|
|
||||||
super(robot, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArduinoFrameFixture(String name) {
|
|
||||||
super(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public JEditTextAreaFixture jEditTextArea(String name) {
|
public JEditTextAreaFixture jEditTextArea(String name) {
|
||||||
return new JEditTextAreaFixture(robot, (JEditTextArea) this.robot.finder().find(new JEditTextAreaComponentMatcher(name)));
|
return new JEditTextAreaFixture(robot, (JEditTextArea) this.robot.finder().find(new JEditTextAreaComponentMatcher(name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Editor getEditor() {
|
||||||
|
return editor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user