Skip to content

Commit 7a0b84f

Browse files
committed
Move validation and dialog to the end of the execution stack
1 parent 750a135 commit 7a0b84f

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

packages/jupyterlab-lsp/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ export class LSPExtension implements ILSPExtension {
205205
formRegistry: formRegistry,
206206
console: this.console.scope('SettingsUIManager'),
207207
languageServerManager: this.language_server_manager,
208-
trans: trans
208+
trans: trans,
209+
restored: app.restored
209210
});
210211
settingsUI
211212
.setupSchemaForUI(plugin.id)

packages/jupyterlab-lsp/src/settings.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ export class SettingsUIManager {
9797
languageServerManager: LanguageServerManager;
9898
console: ILSPLogConsole;
9999
trans: TranslationBundle;
100+
/**
101+
* Promise resolved when JupyterLab splash screen disappears.
102+
*/
103+
restored: Promise<void>;
100104
}
101105
) {
102106
this._defaults = {};
@@ -357,11 +361,14 @@ export class SettingsUIManager {
357361
plugin: ISettingRegistry.IPlugin,
358362
schema: ISettingRegistry.ISchema
359363
) {
360-
// do not re-validate if neither schema, nor user settings changed
364+
// Ensure the subsequent code runs asynchronously; also reduce the CPU load on startup.
365+
await this.options.restored;
366+
367+
// Do not re-validate if neither schema, nor user settings changed
361368
if (this._wasPreviouslyValidated(plugin, schema)) {
362369
return;
363370
}
364-
// test if we can apply the schema without causing validation error
371+
// Test if we can apply the schema without causing validation error
365372
// (is the configuration held by the user compatible with the schema?)
366373
this._validationAttempt += 1;
367374
// the validator will parse raw plugin data into this object;
@@ -370,7 +377,7 @@ export class SettingsUIManager {
370377
const validationErrors =
371378
this.options.settingRegistry.validator.validateData(
372379
{
373-
// the plugin schema is cached so we have to provide a dummy ID;
380+
// The plugin schema is cached so we have to provide a dummy ID;
374381
// can be simplified once https://github.com/jupyterlab/jupyterlab/issues/12978 is fixed.
375382
id: `lsp-validation-attempt-${this._validationAttempt}`,
376383
raw: plugin.raw,
@@ -412,6 +419,10 @@ export class SettingsUIManager {
412419
}
413420

414421
private async _warnConflicts(conflicts: SettingsMergeConflicts) {
422+
// Ensure the subsequent code runs asynchronously, and delay
423+
// showing the dialog until the splash screen disappeared.
424+
await this.options.restored;
425+
415426
showDialog({
416427
body: renderCollapseConflicts({
417428
conflicts: conflicts,

0 commit comments

Comments
 (0)