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 all commits
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
11 changes: 9 additions & 2 deletions packages/codeeditor/src/widget.ts
Expand Up @@ -121,6 +121,9 @@ export class CodeEditorWrapper extends Widget {
node.addEventListener('p-dragleave', this);
node.addEventListener('p-dragover', this);
node.addEventListener('p-drop', this);
// We have to refresh at least once after attaching,
// while visible.
this._hasRefreshedSinceAttach = false;
if (this.isVisible) {
this.update();
}
Expand All @@ -141,7 +144,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._hasRefreshedSinceAttach) {
this.update();
}
}
Expand All @@ -161,7 +164,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._hasRefreshedSinceAttach = true;
this.editor.refresh();
}
}

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

private _updateOnShow: boolean;
private _hasRefreshedSinceAttach = false;
}

/**
Expand Down