Skip to content

Commit

Permalink
Merge pull request #399 from mnowacki-b/context-menu
Browse files Browse the repository at this point in the history
Register Context Commands with already added types
  • Loading branch information
krassowski authored Nov 11, 2020
2 parents fbc9d1c + 4a95fd1 commit 192d016
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
1 change: 1 addition & 0 deletions packages/jupyterlab-lsp/src/adapter_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class WidgetAdapterManager implements ILSPAdapterManager {
type.tracker.widgetAdded.connect((tracker, widget) => {
this.connectWidget(extension, widget, type);
});
extension.registerAdapterType(this, type);
}

public registerExtension(extension: LSPExtension) {
Expand Down
29 changes: 17 additions & 12 deletions packages/jupyterlab-lsp/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
import { ICommandPalette } from '@jupyterlab/apputils';
import { ISettingRegistry } from '@jupyterlab/settingregistry';
import { IDocumentManager } from '@jupyterlab/docmanager';
import { IDocumentWidget } from '@jupyterlab/docregistry';
import { Signal } from '@lumino/signaling';
import { LanguageServerManager } from './manager';
import '../style/index.css';
Expand All @@ -13,6 +14,7 @@ import { IStatusBar } from '@jupyterlab/statusbar';
import { LSPStatus } from './components/statusbar';
import { DocumentConnectionManager } from './connection_manager';
import {
IAdapterTypeOptions,
ILSPAdapterManager,
ILSPCodeExtractorsManager,
ILSPFeatureManager,
Expand Down Expand Up @@ -123,7 +125,7 @@ export class LSPExtension implements ILSPExtension {
constructor(
public app: JupyterFrontEnd,
private setting_registry: ISettingRegistry,
palette: ICommandPalette,
private palette: ICommandPalette,
documentManager: IDocumentManager,
paths: IPaths,
status_bar: IStatusBar,
Expand Down Expand Up @@ -167,19 +169,22 @@ export class LSPExtension implements ILSPExtension {
});

adapterManager.registerExtension(this);
}

adapterManager.adapterTypeAdded.connect((manager, type) => {
let command_manger = new ContextCommandManager({
adapter_manager: adapterManager,
app: app,
palette: palette,
tracker: type.tracker,
suffix: type.name,
entry_point: type.entrypoint,
...type.context_menu
});
this.feature_manager.registerCommandManager(command_manger);
registerAdapterType(
adapterManager: ILSPAdapterManager,
type: IAdapterTypeOptions<IDocumentWidget>
): void {
let command_manger = new ContextCommandManager({
adapter_manager: adapterManager,
app: this.app,
palette: this.palette,
tracker: type.tracker,
suffix: type.name,
entry_point: type.entrypoint,
...type.context_menu
});
this.feature_manager.registerCommandManager(command_manger);
}

get foreign_code_extractors() {
Expand Down

0 comments on commit 192d016

Please sign in to comment.