Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of code editor refresh #7672

Merged
merged 2 commits into from Dec 23, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/codeeditor/src/widget.ts
Expand Up @@ -141,7 +141,7 @@ export class CodeEditorWrapper extends Widget {
* A message handler invoked on an `'after-show'` message.
*/
protected onAfterShow(msg: Message): void {
if (this._updateOnShow) {
if (this._updateOnShow || !this._hasRefreshed) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this should be &&, not ||? Also, should _hasRefreshed be reset to false on hide?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the variable name and added a comment, as well as a reset whenever we attach.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. That name change and comment made the logic clearer. I'll test.

this.update();
}
}
Expand All @@ -161,7 +161,10 @@ export class CodeEditorWrapper extends Widget {
* A message handler invoked on an `'update-request'` message.
*/
protected onUpdateRequest(msg: Message): void {
this.editor.refresh();
if (this.isVisible) {
this._hasRefreshed = true;
this.editor.refresh();
}
}

/**
Expand Down Expand Up @@ -275,6 +278,7 @@ export class CodeEditorWrapper extends Widget {
}

private _updateOnShow: boolean;
private _hasRefreshed = false;
}

/**
Expand Down