File tree Expand file tree Collapse file tree 3 files changed +53
-18
lines changed
Expand file tree Collapse file tree 3 files changed +53
-18
lines changed Original file line number Diff line number Diff line change @@ -1693,10 +1693,11 @@ protected void setCode(SketchCodeDocument codeDoc) {
16931693 document .addUndoableEditListener (new UndoableEditListener () {
16941694 public void undoableEditHappened (UndoableEditEvent e ) {
16951695 if (compoundEdit != null ) {
1696- compoundEdit .addEdit (e .getEdit ());
1697-
1696+ compoundEdit .addEdit (new CaretAwareUndoableEdit (e .getEdit (), textarea ));
16981697 } else if (undo != null ) {
16991698 undo .addEdit (new CaretAwareUndoableEdit (e .getEdit (), textarea ));
1699+ }
1700+ if (compoundEdit != null || undo != null ) {
17001701 sketch .setModified (true );
17011702 undoAction .updateUndoState ();
17021703 redoAction .updateRedoState ();
Original file line number Diff line number Diff line change 1+ package processing .app ;
2+
3+ import org .fest .swing .edt .GuiActionRunner ;
4+ import org .fest .swing .edt .GuiQuery ;
5+ import org .fest .swing .fixture .JMenuItemFixture ;
6+ import org .junit .Test ;
7+ import processing .app .helpers .JEditTextAreaFixture ;
8+
9+ import java .awt .*;
10+
11+ import static org .junit .Assert .assertEquals ;
12+
13+ public class BlockCommentGeneratesOneUndoActionTest extends AbstractGUITest {
14+
15+ @ Test
16+ public void shouldUndoAndRedo () throws Exception {
17+ JMenuItemFixture menuEditUndo = window .menuItem ("menuEditUndo" );
18+ menuEditUndo .requireDisabled ();
19+
20+ JEditTextAreaFixture jEditTextArea = window .jEditTextArea ("editor" );
21+ String previousText = jEditTextArea .getText ();
22+
23+ jEditTextArea .selectAll ();
24+
25+ GuiActionRunner .execute (new GuiQuery <Frame >() {
26+
27+ protected Frame executeInEDT () {
28+ window .getEditor ().handleCommentUncomment ();
29+ return window .getEditor ();
30+ }
31+
32+ });
33+
34+ menuEditUndo .requireEnabled ();
35+ menuEditUndo .click ();
36+
37+ assertEquals (previousText , jEditTextArea .getText ());
38+
39+ menuEditUndo .requireDisabled ();
40+ }
41+ }
Original file line number Diff line number Diff line change 11package processing .app .helpers ;
22
3- import org .fest .swing .core .Robot ;
43import org .fest .swing .fixture .FrameFixture ;
4+ import processing .app .Editor ;
55import processing .app .syntax .JEditTextArea ;
66
7- import java .awt .*;
8-
97public class ArduinoFrameFixture extends FrameFixture {
108
11- public ArduinoFrameFixture (Frame target ) {
12- super (target );
13- }
14-
15- public ArduinoFrameFixture (org .fest .swing .core .Robot robot , Frame target ) {
16- super (robot , target );
17- }
18-
19- public ArduinoFrameFixture (Robot robot , String name ) {
20- super (robot , name );
21- }
9+ private final Editor editor ;
2210
23- public ArduinoFrameFixture (String name ) {
24- super (name );
11+ public ArduinoFrameFixture (Editor editor ) {
12+ super (editor );
13+ this .editor = editor ;
2514 }
2615
2716 public JEditTextAreaFixture jEditTextArea (String name ) {
2817 return new JEditTextAreaFixture (robot , (JEditTextArea ) this .robot .finder ().find (new JEditTextAreaComponentMatcher (name )));
2918 }
19+
20+ public Editor getEditor () {
21+ return editor ;
22+ }
3023}
You can’t perform that action at this time.
0 commit comments