5
5
import { ICommandPalette } from '@jupyterlab/apputils' ;
6
6
import { ISettingRegistry } from '@jupyterlab/settingregistry' ;
7
7
import { IDocumentManager } from '@jupyterlab/docmanager' ;
8
+ import { IDocumentWidget } from '@jupyterlab/docregistry' ;
8
9
import { Signal } from '@lumino/signaling' ;
9
10
import { LanguageServerManager } from './manager' ;
10
11
import '../style/index.css' ;
@@ -13,6 +14,7 @@ import { IStatusBar } from '@jupyterlab/statusbar';
13
14
import { LSPStatus } from './components/statusbar' ;
14
15
import { DocumentConnectionManager } from './connection_manager' ;
15
16
import {
17
+ IAdapterTypeOptions ,
16
18
ILSPAdapterManager ,
17
19
ILSPCodeExtractorsManager ,
18
20
ILSPFeatureManager ,
@@ -26,7 +28,7 @@ import { SIGNATURE_PLUGIN } from './features/signature';
26
28
import { HOVER_PLUGIN } from './features/hover' ;
27
29
import { RENAME_PLUGIN } from './features/rename' ;
28
30
import { HIGHLIGHTS_PLUGIN } from './features/highlights' ;
29
- import { WIDGET_ADAPTER_MANAGER } from './adapter_manager' ;
31
+ import { WidgetAdapterManager , WIDGET_ADAPTER_MANAGER } from './adapter_manager' ;
30
32
import { FILE_EDITOR_ADAPTER } from './adapters/file_editor' ;
31
33
import { NOTEBOOK_ADAPTER } from './adapters/notebook' ;
32
34
import { VIRTUAL_EDITOR_MANAGER } from './virtual/editor' ;
@@ -166,9 +168,7 @@ export class LSPExtension implements ILSPExtension {
166
168
console . error ( reason . message ) ;
167
169
} ) ;
168
170
169
- adapterManager . registerExtension ( this ) ;
170
-
171
- adapterManager . adapterTypeAdded . connect ( ( manager , type ) => {
171
+ const registerContextCommandManager = ( type : IAdapterTypeOptions < IDocumentWidget > ) : void => {
172
172
let command_manger = new ContextCommandManager ( {
173
173
adapter_manager : adapterManager ,
174
174
app : app ,
@@ -179,6 +179,18 @@ export class LSPExtension implements ILSPExtension {
179
179
...type . context_menu
180
180
} ) ;
181
181
this . feature_manager . registerCommandManager ( command_manger ) ;
182
+ } ;
183
+
184
+ // Register context commands with already added types
185
+ adapterManager . types . forEach ( ( type : IAdapterTypeOptions < IDocumentWidget > ) => {
186
+ registerContextCommandManager ( type ) ;
187
+ } ) ;
188
+
189
+ adapterManager . registerExtension ( this ) ;
190
+
191
+ // Register context commands with any types that may be added later
192
+ adapterManager . adapterTypeAdded . connect ( ( manager : WidgetAdapterManager , type : IAdapterTypeOptions < IDocumentWidget > ) => {
193
+ registerContextCommandManager ( type ) ;
182
194
} ) ;
183
195
}
184
196
0 commit comments