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

feat: add support in command palette for category #4531

Merged
merged 1 commit into from Oct 27, 2023
Merged
Show file tree
Hide file tree
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
36 changes: 36 additions & 0 deletions packages/main/src/plugin/command-registry.spec.ts
Expand Up @@ -120,3 +120,39 @@ test('Should dispose global commands ', async () => {
expectTypeOf(commandPaletteCommandsAfter2).toBeArray();
expect(commandPaletteCommandsAfter2.length).toBe(0);
});

test('Should include category in the title', async () => {
const myCommandId1 = 'my-extension.command1';
const title1 = 'My dummy Command 1';

const myCommandId2 = 'my-extension.command2';
const title2 = 'My dummy Command 2';

const category = 'My Category';

commandRegistry.registerCommandsFromExtension('my-extension', [
{
command: myCommandId1,
title: title1,
category,
},
{
command: myCommandId2,
title: title2,
category,
},
]);

// grab all commands
const commandPaletteCommands = commandRegistry.getCommandPaletteCommands();
expect(commandPaletteCommands).toBeDefined();
expectTypeOf(commandPaletteCommands).toBeArray();
expect(commandPaletteCommands.length).toBe(2);

// check we have our command
const myCommand = commandPaletteCommands.find(command => command.id === myCommandId1);
expect(myCommand).toBeDefined();

// should have category + title
expect(myCommand?.title).toBe(`${category}: ${title1}`);
});
2 changes: 1 addition & 1 deletion packages/main/src/plugin/command-registry.ts
Expand Up @@ -103,7 +103,7 @@ export class CommandRegistry {
}
commandInfos.push({
id: command.command,
title: command.title,
title: command.category ? `${command.category}: ${command.title}` : command.title,
});
});
});
Expand Down