Skip to content

Commit cdc740d

Browse files
committed
Fix diagnostics panel not working after restart
1 parent 24fe761 commit cdc740d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/jupyterlab-lsp/src/features/diagnostics/diagnostics.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,6 @@ export class DiagnosticsCM extends CodeMirrorIntegration {
275275
this.connection_handlers.set('diagnostic', this.handleDiagnostic);
276276
this.wrapper_handlers.set('focusin', this.switchDiagnosticsPanelSource);
277277
this.unique_editor_ids = new DefaultMap(() => this.unique_editor_ids.size);
278-
if (!diagnostics_databases.has(this.virtual_editor)) {
279-
diagnostics_databases.set(this.virtual_editor, new DiagnosticsDatabase());
280-
}
281-
this.diagnostics_db = diagnostics_databases.get(this.virtual_editor);
282278
this.settings.changed.connect(this.refreshDiagnostics, this);
283279
super.register();
284280
}
@@ -294,7 +290,13 @@ export class DiagnosticsCM extends CodeMirrorIntegration {
294290
*
295291
* Maps virtual_document.uri to IEditorDiagnostic[].
296292
*/
297-
public diagnostics_db: DiagnosticsDatabase;
293+
public get diagnostics_db(): DiagnosticsDatabase {
294+
// Note that virtual_editor can change at runtime (kernel restart)
295+
if (!diagnostics_databases.has(this.virtual_editor)) {
296+
diagnostics_databases.set(this.virtual_editor, new DiagnosticsDatabase());
297+
}
298+
return diagnostics_databases.get(this.virtual_editor);
299+
}
298300

299301
switchDiagnosticsPanelSource = () => {
300302
if (

0 commit comments

Comments
 (0)