Skip to content

Commit

Permalink
Fix compiler-explorer#6801: handle changeLangage before selectize ini…
Browse files Browse the repository at this point in the history
…tialization
  • Loading branch information
OfekShilon committed Aug 30, 2024
1 parent fee185b commit 50efec5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions static/panes/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class Editor extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Edit
private revealJumpStack: editor.ICodeEditorViewState[];
private langKeys: string[];
private legacyReadOnly?: boolean;
private selectize: TomSelect;
private selectize?: TomSelect;
private lastChangeEmitted: string | null;
private languageBtn: JQuery<HTMLElement>;
public currentLanguage?: Language;
Expand Down Expand Up @@ -889,10 +889,15 @@ export class Editor extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Edit
}

changeLanguage(newLang: string): void {
if (newLang === 'cmake') {
this.selectize.addOption(unwrap(languages.cmake));
if (!this.selectize) {
// In some initialization flows we get here before creating this.selectize
setTimeout(() => this.changeLanguage(newLang), 0);
} else {
if (newLang === 'cmake') {
this.selectize.addOption(unwrap(languages.cmake));
}
this.selectize.setValue(newLang);
}
this.selectize.setValue(newLang);
}

clearLinkedLine() {
Expand Down

0 comments on commit 50efec5

Please sign in to comment.