Skip to content

Commit

Permalink
fix: updateOptions some time call be undefind
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Aug 10, 2022
1 parent 123ab48 commit 7fdb906
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.tab_text {
max-width: 90px;
font-weight: 500;
}
::ng-deep {
eo-api-tab {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,10 @@ export class EoMonacoEditorComponent implements AfterViewInit, OnInit, OnChanges
};
formatCode() {
return new Promise<string>((resolve) => {
requestAnimationFrame(async () => {
this.codeEdtor.updateOptions({ readOnly: false });
requestIdleCallback(async () => {
this.codeEdtor?.updateOptions({ readOnly: false });
await this.codeEdtor?.getAction('editor.action.formatDocument')?.run();
this.codeEdtor.updateOptions({ readOnly: this.config.readOnly });
this.codeEdtor?.updateOptions({ readOnly: this.config.readOnly });
resolve(this.codeEdtor?.getValue() || '');
});
});
Expand Down

0 comments on commit 7fdb906

Please sign in to comment.