From 1c3745cdf89ec4b171e3dd8bc8ccd97b0cd7dfcc Mon Sep 17 00:00:00 2001 From: modmuss Date: Thu, 28 Mar 2024 18:43:48 +0000 Subject: Clear undo history when updating editor text. (#540) We don't care about the undo/redo history of the syntax pane, any change history would be stored separately--- .../src/main/java/cuchaz/enigma/gui/panels/EditorPanel.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/panels/EditorPanel.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/panels/EditorPanel.java index b285689e..e0a299f5 100644 --- a/enigma-swing/src/main/java/cuchaz/enigma/gui/panels/EditorPanel.java +++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/panels/EditorPanel.java @@ -35,6 +35,7 @@ import javax.swing.text.Document; import javax.swing.text.Highlighter.HighlightPainter; import de.sciss.syntaxpane.DefaultSyntaxKit; +import de.sciss.syntaxpane.SyntaxDocument; import cuchaz.enigma.EnigmaProject; import cuchaz.enigma.analysis.EntryReference; @@ -504,6 +505,11 @@ public class EditorPanel { this.editor.getHighlighter().removeAllHighlights(); this.editor.setText(source.toString()); + // We don't care about the undo/redo history of the syntax pane, any change history would be stored separately + if (this.editor.getDocument() instanceof SyntaxDocument syntaxDocument) { + syntaxDocument.clearUndos(); + } + if (this.source != null) { this.editor.setCaretPosition(newCaretPos); } -- cgit v1.2.3