From 294a830b5572067285de86acafc8137755ec9c88 Mon Sep 17 00:00:00 2001 From: bobbylight Date: Tue, 19 Nov 2024 23:11:39 -0500 Subject: [PATCH] Fix #541: Line numbers resize when getting a new document --- .../ui/rtextarea/AbstractGutterComponent.java | 16 ++++++++++++++++ .../main/java/org/fife/ui/rtextarea/Gutter.java | 5 +++++ .../org/fife/ui/rtextarea/LineNumberList.java | 9 +++++++++ 3 files changed, 30 insertions(+) diff --git a/RSyntaxTextArea/src/main/java/org/fife/ui/rtextarea/AbstractGutterComponent.java b/RSyntaxTextArea/src/main/java/org/fife/ui/rtextarea/AbstractGutterComponent.java index c933382b6..e6c956de1 100755 --- a/RSyntaxTextArea/src/main/java/org/fife/ui/rtextarea/AbstractGutterComponent.java +++ b/RSyntaxTextArea/src/main/java/org/fife/ui/rtextarea/AbstractGutterComponent.java @@ -110,10 +110,26 @@ private static Listener getListener() { * Implementations can take this opportunity to repaint, revalidate, etc. * * @param e The document event. + * @see #handleDocumentUpdated(RDocument, RDocument) */ abstract void handleDocumentEvent(DocumentEvent e); + /** + * Called when the document is updated. This happens when an application + * calls {@code textArea.read(reader)}, for example.

+ * + * The default implementation does nothing. Subclasses can override. + * + * @param oldDoc The old document, which may be {@code null}. + * @param newDoc The new document, which may be {@code null}. + * @see #handleDocumentEvent(DocumentEvent) + */ + void handleDocumentUpdated(RDocument oldDoc, RDocument newDoc) { + // Do nothing + } + + /** * Called by the constructor before the text area is set. This is a hook * to allow subclasses to do any needed initialization. The default diff --git a/RSyntaxTextArea/src/main/java/org/fife/ui/rtextarea/Gutter.java b/RSyntaxTextArea/src/main/java/org/fife/ui/rtextarea/Gutter.java index 9fd294c50..0f4f8d965 100755 --- a/RSyntaxTextArea/src/main/java/org/fife/ui/rtextarea/Gutter.java +++ b/RSyntaxTextArea/src/main/java/org/fife/ui/rtextarea/Gutter.java @@ -1260,6 +1260,11 @@ else if ("document".equals(name)) { if (newDoc != null) { newDoc.addDocumentListener(this); } + for (int i=0; i