Skip to content

Commit

Permalink
fixed terminal contribution menu and execution of vsx contributed com…
Browse files Browse the repository at this point in the history
…mands

Signed-off-by: Jonah Iden <[email protected]>
  • Loading branch information
jonah-iden committed Feb 8, 2024
1 parent 87516db commit d508b5e
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/browser/shell/tab-bars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ export class TabBarRenderer extends TabBar.Renderer {
this.selectionService.selection = NavigatableWidget.is(widget) ? { uri: widget.getResourceUri() } : widget;
}

const contextKeyServiceOverly = this.contextKeyService?.createOverlay([['tabContextWidgetId', widget?.id]]);
const contextKeyServiceOverly = this.contextKeyService?.createOverlay([['isTerminalTab', widget && '_terminalId' in widget]]);
this.contextMenuRenderer.render({
menuPath: this.contextMenuPath!,
anchor: event,
Expand Down
7 changes: 7 additions & 0 deletions packages/plugin-ext/src/main/browser/command-registry-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import { RPCProtocol } from '../../common/rpc-protocol';
import { KeybindingRegistry } from '@theia/core/lib/browser';
import { PluginContributionHandler } from './plugin-contribution-handler';
import { ArgumentProcessor } from '../../common/commands';
import { ContributionProvider } from '@theia/core';

export const ArgumentProcessorContribution = Symbol('ArgumentProcessorContribution');

export class CommandRegistryMainImpl implements CommandRegistryMain, Disposable {
private readonly proxy: CommandRegistryExt;
Expand All @@ -41,6 +44,10 @@ export class CommandRegistryMainImpl implements CommandRegistryMain, Disposable
this.delegate = container.get(CommandRegistry);
this.keyBinding = container.get(KeybindingRegistry);
this.contributions = container.get(PluginContributionHandler);

container.getNamed<ContributionProvider<ArgumentProcessor>>(ContributionProvider, ArgumentProcessorContribution).getContributions().forEach(processor => {
this.registerArgumentProcessor(processor);
});
}

dispose(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import { TabBarToolbarContribution } from '@theia/core/lib/browser/shell/tab-bar
import { CellOutputWebviewFactory } from '@theia/notebook/lib/browser';
import { CellOutputWebviewImpl, createCellOutputWebviewContainer } from './notebooks/renderers/cell-output-webview';
import { NotebookCellModel } from '@theia/notebook/lib/browser/view-model/notebook-cell-model';
import { ArgumentProcessorContribution } from './command-registry-main';

export default new ContainerModule((bind, unbind, isBound, rebind) => {

Expand Down Expand Up @@ -265,4 +266,6 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
bind(CellOutputWebviewFactory).toFactory(ctx => async (cell: NotebookCellModel) =>
createCellOutputWebviewContainer(ctx.container, cell).getAsync(CellOutputWebviewImpl)
);

bindContributionProvider(bind, ArgumentProcessorContribution);
});
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ export class TerminalFrontendContribution implements FrontendApplicationContribu

menus.registerSubmenu(TerminalMenus.TERMINAL_TITLE_CONTRIBUTIONS, '', {
role: CompoundMenuNodeRole.Group,
when: 'tabContextWidgetId =~ /^terminal-[0-9]+$/'
when: 'isTerminalTab'
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// *****************************************************************************
// Copyright (C) 2024 TypeFox and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0.
//
// This Source Code may also be made available under the following Secondary
// Licenses when the conditions for such availability set forth in the Eclipse
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
// with the GNU Classpath Exception which is available at
// https://www.gnu.org/software/classpath/license.html.
//
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

import { injectable } from '@theia/core/shared/inversify';
import { ArgumentProcessor } from '@theia/plugin-ext/lib/common/commands';
import { VSXExtension } from './vsx-extension';

@injectable()
export class VsxExtensionArgumentProcessor implements ArgumentProcessor {

processArgument(arg: unknown): unknown {
if (arg instanceof VSXExtension) {
return arg.id;
}

return arg;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import { bindPreferenceProviderOverrides } from './recommended-extensions/prefer
import { VSXEnvironment, VSX_ENVIRONMENT_PATH } from '../common/vsx-environment';
import { LanguageQuickPickService } from '@theia/core/lib/browser/i18n/language-quick-pick-service';
import { VSXLanguageQuickPickService } from './vsx-language-quick-pick-service';
import { VsxExtensionArgumentProcessor } from './vsx-extension-argument-processor';
import { ArgumentProcessorContribution } from '@theia/plugin-ext/lib/main/browser/command-registry-main';

export default new ContainerModule((bind, unbind, isBound, rebind) => {
bind(VSXEnvironment)
Expand Down Expand Up @@ -103,4 +105,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {

bindExtensionPreferences(bind);
bindPreferenceProviderOverrides(bind, unbind);

bind(VsxExtensionArgumentProcessor).toSelf().inSingletonScope();
bind(ArgumentProcessorContribution).toService(VsxExtensionArgumentProcessor);
});

0 comments on commit d508b5e

Please sign in to comment.