Skip to content

Commit

Permalink
Fix #541: Line numbers resize when getting a new document
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbylight committed Nov 20, 2024
1 parent d5ca68d commit 294a830
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.<p>
*
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,11 @@ else if ("document".equals(name)) {
if (newDoc != null) {
newDoc.addDocumentListener(this);
}
for (int i=0; i<getComponentCount(); i++) {
AbstractGutterComponent agc =
(AbstractGutterComponent)getComponent(i);
agc.handleDocumentUpdated(old, newDoc);
}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,15 @@ void handleDocumentEvent(DocumentEvent e) {
}


/**
* Overridden to update the width of this component.
*/
@Override
void handleDocumentUpdated(RDocument oldDoc, RDocument newDoc) {
updateCellWidths();
}


@Override
protected void init() {

Expand Down

0 comments on commit 294a830

Please sign in to comment.