Skip to content

Commit 1a80997

Browse files
committed
Ensure file editor extension will not be added twice in future
1 parent a0b6082 commit 1a80997

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

packages/jupyterlab-lsp/src/adapters/fileeditor.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import {
1212
import {
1313
ILSPCodeExtractorsManager,
1414
ILSPFeatureManager,
15-
ILSPDocumentConnectionManager
15+
ILSPDocumentConnectionManager,
16+
IEditorChangedData
1617
} from '@jupyterlab/lsp';
1718

1819
import { ILSPCodeOverridesManager } from '../overrides/tokens';
@@ -28,6 +29,18 @@ export class FileEditorAdapter extends UpstreamFileEditorAdapter {
2829
protected options: IAdapterOptions
2930
) {
3031
super(editorWidget, options);
32+
// Workaround to ensure `_editorAdded` is not called twice once upstream
33+
// adopts patch https://github.com/jupyterlab/jupyterlab/pull/15873
34+
let emitted = false;
35+
const emit = this._editorAdded.emit;
36+
this._editorAdded.emit = (args: IEditorChangedData) => {
37+
if (emitted) {
38+
return;
39+
}
40+
emitted = true;
41+
console.log('call');
42+
emit.call(this._editorAdded, args);
43+
};
3144
}
3245

3346
protected async initOnceReady(): Promise<void> {

0 commit comments

Comments
 (0)