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) {
1693
1693
document .addUndoableEditListener (new UndoableEditListener () {
1694
1694
public void undoableEditHappened (UndoableEditEvent e ) {
1695
1695
if (compoundEdit != null ) {
1696
- compoundEdit .addEdit (e .getEdit ());
1697
-
1696
+ compoundEdit .addEdit (new CaretAwareUndoableEdit (e .getEdit (), textarea ));
1698
1697
} else if (undo != null ) {
1699
1698
undo .addEdit (new CaretAwareUndoableEdit (e .getEdit (), textarea ));
1699
+ }
1700
+ if (compoundEdit != null || undo != null ) {
1700
1701
sketch .setModified (true );
1701
1702
undoAction .updateUndoState ();
1702
1703
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 1
1
package processing .app .helpers ;
2
2
3
- import org .fest .swing .core .Robot ;
4
3
import org .fest .swing .fixture .FrameFixture ;
4
+ import processing .app .Editor ;
5
5
import processing .app .syntax .JEditTextArea ;
6
6
7
- import java .awt .*;
8
-
9
7
public class ArduinoFrameFixture extends FrameFixture {
10
8
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 ;
22
10
23
- public ArduinoFrameFixture (String name ) {
24
- super (name );
11
+ public ArduinoFrameFixture (Editor editor ) {
12
+ super (editor );
13
+ this .editor = editor ;
25
14
}
26
15
27
16
public JEditTextAreaFixture jEditTextArea (String name ) {
28
17
return new JEditTextAreaFixture (robot , (JEditTextArea ) this .robot .finder ().find (new JEditTextAreaComponentMatcher (name )));
29
18
}
19
+
20
+ public Editor getEditor () {
21
+ return editor ;
22
+ }
30
23
}
You can’t perform that action at this time.
0 commit comments