mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-07-16 17:26:58 -04:00
fix: apply shortlink libraries before compiling after lazy-load
The lazy-load change (#8549) made the LibsWidget fetch its available library list from the API, so applying the saved state (selecting the libraries from a shortlink) became asynchronous. The compiler/executor panes called initLibraries without awaiting it and then immediately compiled and persisted state, so the saved libraries were not yet selected (e.g. /z/jMdjdahn6 loaded without beman_any_view selected). Expose a stateLoaded promise on LibsWidget that resolves once loadState has run, await it in initLibraries, and await initLibraries in postInit. Also refresh the libraries button after loadState so its count is correct. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -363,7 +363,7 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
|
||||
this.compiler?.id ?? '',
|
||||
this.onCompilerChange.bind(this),
|
||||
);
|
||||
this.initLibraries(state);
|
||||
await this.initLibraries(state);
|
||||
this.sendCompiler();
|
||||
this.updateCompilerInfo();
|
||||
this.updateButtons();
|
||||
@@ -2646,6 +2646,8 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
|
||||
this.compiler?.remote,
|
||||
),
|
||||
);
|
||||
// Wait for the lazily-loaded libraries to be selected before compiling or persisting state.
|
||||
await this.libsWidget.stateLoaded;
|
||||
}
|
||||
|
||||
async updateLibraries(): Promise<void> {
|
||||
|
||||
@@ -186,7 +186,7 @@ export class Executor extends Pane<ExecutorState> {
|
||||
this.compilerIsVisible,
|
||||
);
|
||||
|
||||
this.initLibraries(state);
|
||||
await this.initLibraries(state);
|
||||
this.updateCompilerInfo();
|
||||
this.updateState();
|
||||
|
||||
@@ -906,6 +906,8 @@ export class Executor extends Pane<ExecutorState> {
|
||||
this.compiler?.remote ?? undefined,
|
||||
),
|
||||
);
|
||||
// Wait for the lazily-loaded libraries to be selected before compiling or persisting state.
|
||||
await this.libsWidget.stateLoaded;
|
||||
}
|
||||
|
||||
onFontScale(): void {
|
||||
|
||||
@@ -139,6 +139,9 @@ export class LibsWidget {
|
||||
|
||||
private readonly onChangeCallback: () => void;
|
||||
|
||||
// Resolves once the saved state has been applied to the lazily-loaded library list.
|
||||
public readonly stateLoaded: Promise<void>;
|
||||
|
||||
private readonly availableLibs: AvailableLibs;
|
||||
private readonly filters: PopupAlertFilter[] = [
|
||||
(compilerId, langId) => {
|
||||
@@ -176,9 +179,10 @@ export class LibsWidget {
|
||||
this.initButtons();
|
||||
this.onChangeCallback = onChangeCallback;
|
||||
this.availableLibs = {};
|
||||
this.updateAvailableLibs(possibleLibs, true).then(() => {
|
||||
this.stateLoaded = this.updateAvailableLibs(possibleLibs, true).then(() => {
|
||||
this.loadState(state);
|
||||
this.fullRefresh();
|
||||
this.updateButton();
|
||||
});
|
||||
|
||||
const searchInput = this.domRoot.find('.lib-search-input');
|
||||
|
||||
Reference in New Issue
Block a user