mirror of
https://github.com/processing/processing4.git
synced 2026-02-13 18:35:37 +01:00
Fixed bug that caused Comment/Uncomment to register as multiple undos
This commit is contained in:
@@ -230,7 +230,7 @@ public abstract class Editor extends JFrame implements RunnerListener {
|
||||
|
||||
public void caretUpdate(CaretEvent e) {
|
||||
String newText = textarea.getText();
|
||||
if (lastText.equals(newText)) {
|
||||
if (lastText.equals(newText) && isDirectEdit()) {
|
||||
endTextEditHistory();
|
||||
}
|
||||
lastText = newText;
|
||||
@@ -1367,14 +1367,16 @@ public abstract class Editor extends JFrame implements RunnerListener {
|
||||
document.addDocumentListener(new DocumentListener() {
|
||||
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
if (isInserting)
|
||||
if (isInserting && isDirectEdit()) {
|
||||
endTextEditHistory();
|
||||
}
|
||||
isInserting = false;
|
||||
}
|
||||
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
if (!isInserting)
|
||||
if (!isInserting && isDirectEdit()) {
|
||||
endTextEditHistory();
|
||||
}
|
||||
isInserting = true;
|
||||
}
|
||||
|
||||
@@ -1420,6 +1422,14 @@ public abstract class Editor extends JFrame implements RunnerListener {
|
||||
redoAction.updateRedoState();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the text is being edited from direct input from typing and
|
||||
* not shortcuts that manipulate text
|
||||
*/
|
||||
boolean isDirectEdit() {
|
||||
return endUndoEvent != null;
|
||||
}
|
||||
|
||||
void startTimerEvent() {
|
||||
endUndoEvent = new TimerTask() {
|
||||
public void run() {
|
||||
|
||||
Reference in New Issue
Block a user