Skip to content

Commit 53c868f

Browse files
committed
Restore after change to prevent errors, handle the failures
1 parent 70352bb commit 53c868f

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

packages/jupyterlab-lsp/src/editor_integration/codemirror.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
} from '../virtual/codemirror_editor';
2424
import { StatusMessage, WidgetAdapter } from '../adapters/adapter';
2525
import { IDocumentWidget } from '@jupyterlab/docregistry';
26+
import { IEditorChange } from '../virtual/editor';
2627

2728
function toDocumentChanges(changes: {
2829
[uri: string]: lsProtocol.TextEdit[];
@@ -407,6 +408,10 @@ export abstract class CodeMirrorIntegration
407408
return 1;
408409
}
409410

411+
afterChange(change: IEditorChange, root_position: IRootPosition) {
412+
// nothing here
413+
}
414+
410415
protected apply_single_edit(edit: lsProtocol.TextEdit): number {
411416
let document = this.virtual_document;
412417
let applied_changes = 0;

packages/jupyterlab-lsp/src/editor_integration/editor_adapter.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ export class EditorAdapter<T extends IVirtualEditor<IEditor>> {
7575
}
7676

7777
for (let feature of this.features.values()) {
78-
feature.afterChange(change, root_position);
78+
try {
79+
feature.afterChange(change, root_position);
80+
} catch (err) {
81+
console.warn('afterChange of feature', feature, 'failed with', err);
82+
}
7983
}
8084
return true;
8185
} catch (e) {

0 commit comments

Comments
 (0)