mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-22 08:22:04 +03:00
first functional test made with FEST: simulation of user interaction with the IDE
found and solved a bug with caret positioning with a cleared editor (see #1288)
This commit is contained in:
@ -232,6 +232,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
upper.add(header);
|
||||
|
||||
textarea = new JEditTextArea(new PdeTextAreaDefaults());
|
||||
textarea.setName("editor");
|
||||
textarea.setRightClickPopup(new TextAreaPopup());
|
||||
textarea.setHorizontalOffset(6);
|
||||
|
||||
@ -1135,9 +1136,11 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
protected JMenu buildEditMenu() {
|
||||
JMenu menu = new JMenu(_("Edit"));
|
||||
menu.setName("menuEdit");
|
||||
JMenuItem item;
|
||||
|
||||
undoItem = newJMenuItem(_("Undo"), 'Z');
|
||||
undoItem.setName("menuEditUndo");
|
||||
undoItem.addActionListener(undoAction = new UndoAction());
|
||||
menu.add(undoItem);
|
||||
|
||||
@ -1146,6 +1149,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
} else {
|
||||
redoItem = newJMenuItemShift(_("Redo"), 'Z');
|
||||
}
|
||||
redoItem.setName("menuEditRedo");
|
||||
redoItem.addActionListener(redoAction = new RedoAction());
|
||||
menu.add(redoItem);
|
||||
|
||||
@ -1345,7 +1349,10 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
}
|
||||
if (undo.getLastUndoableEdit() != null && undo.getLastUndoableEdit() instanceof CaretAwareUndoableEdit) {
|
||||
CaretAwareUndoableEdit undoableEdit = (CaretAwareUndoableEdit) undo.getLastUndoableEdit();
|
||||
textarea.setCaretPosition(undoableEdit.getCaretPosition() - 1);
|
||||
int nextCaretPosition = undoableEdit.getCaretPosition() - 1;
|
||||
if (nextCaretPosition >= 0 && textarea.getDocumentLength() > nextCaretPosition) {
|
||||
textarea.setCaretPosition(nextCaretPosition);
|
||||
}
|
||||
}
|
||||
updateUndoState();
|
||||
redoAction.updateRedoState();
|
||||
|
Reference in New Issue
Block a user