Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Continue On options to specify standalone command names #167111

Merged
merged 3 commits into from Nov 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -57,6 +57,7 @@ import { sha1Hex } from 'vs/base/browser/hash';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
import { IActivityService, NumberBadge } from 'vs/workbench/services/activity/common/activity';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { ILocalizedString } from 'vs/platform/action/common/action';
import { Codicon } from 'vs/base/common/codicons';

registerSingleton(IEditSessionsLogService, EditSessionsLogService, InstantiationType.Delayed);
Expand Down Expand Up @@ -290,7 +291,7 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
super(continueWorkingOnCommand);
}

async run(accessor: ServicesAccessor, workspaceUri: URI | undefined): Promise<void> {
async run(accessor: ServicesAccessor, workspaceUri: URI | undefined, destination: string | undefined): Promise<void> {
type ContinueEditSessionEvent = {};
type ContinueEditSessionClassification = {
owner: 'joyceerhl'; comment: 'Reporting when the continue edit session action is run.';
Expand All @@ -299,12 +300,11 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo

// First ask the user to pick a destination, if necessary
let uri: URI | 'noDestinationUri' | undefined = workspaceUri;
let destination;
if (!uri) {
destination = await that.pickContinueEditSessionDestination();
}
if (!destination && !uri) {
return;
destination = await that.pickContinueEditSessionDestination();
if (!destination) {
return;
}
}

// Determine if we need to store an edit session, asking for edit session auth if necessary
Expand Down Expand Up @@ -731,20 +731,43 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo

const icon = command.icon;
const title = typeof command.title === 'string' ? command.title : command.title.value;
const when = ContextKeyExpr.deserialize(contribution.when);

continueEditSessionOptions.push(new ContinueEditSessionItem(
ThemeIcon.isThemeIcon(icon) ? `$(${icon.id}) ${title}` : title,
command.id,
command.source,
ContextKeyExpr.deserialize(contribution.when),
when,
contribution.documentation
));

if (contribution.qualifiedName) {
this.generateStandaloneOptionCommand(command.id, contribution.qualifiedName, command.category, when);
}
}
}
this.continueEditSessionOptions = continueEditSessionOptions;
});
}

private generateStandaloneOptionCommand(commandId: string, qualifiedName: string, category: string | ILocalizedString | undefined, when: ContextKeyExpression | undefined) {
registerAction2(class StandaloneContinueOnOption extends Action2 {
constructor() {
super({
id: `${continueWorkingOnCommand.id}.${commandId}`,
title: { original: qualifiedName, value: qualifiedName },
category: typeof category === 'string' ? { original: category, value: category } : category,
precondition: when,
f1: true
});
}

async run(accessor: ServicesAccessor): Promise<void> {
return accessor.get(ICommandService).executeCommand(continueWorkingOnCommand.id, undefined, commandId);
}
});
}

private registerContinueInLocalFolderAction(): void {
const that = this;
this._register(registerAction2(class ContinueInLocalFolderAction extends Action2 {
Expand Down Expand Up @@ -858,6 +881,7 @@ interface ICommand {
group: string;
when: string;
documentation?: string;
qualifiedName?: string;
}

const continueEditSessionExtPoint = ExtensionsRegistry.registerExtensionPoint<ICommand[]>({
Expand All @@ -876,6 +900,10 @@ const continueEditSessionExtPoint = ExtensionsRegistry.registerExtensionPoint<IC
description: localize('continueEditSessionExtPoint.group', 'Group into which this item belongs.'),
type: 'string'
},
qualifiedName: {
description: localize('continueEditSessionExtPoint.qualifiedName', 'A fully qualified name for this item which is used for display in menus.'),
type: 'string'
},
description: {
description: localize('continueEditSessionExtPoint.description', "The url, or a command that returns the url, to the option's documentation page."),
type: 'string'
Expand Down