Skip to content

Commit

Permalink
fix: remove group from parent group when unregistering
Browse files Browse the repository at this point in the history
  • Loading branch information
paradoxuum committed Aug 23, 2024
1 parent 41fb465 commit 41411af
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions packages/core/src/shared/core/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,18 +244,21 @@ export abstract class BaseRegistry<
*/
unregisterCommand(path: RegistryPath) {
const command = this.getCommand(path);
this.logger.assert(command !== undefined, `Command not found: ${path}`);

for (const path of command.getPaths()) {
this.commands.delete(path.toString());
this.uncachePath(path);
}
this.logger.assert(
command !== undefined,
`Command is not registered: ${path}`,
);

const group = this.getGroup(path.parent());
if (group !== undefined) {
group.removeCommand(command);
}

for (const path of command.getPaths()) {
this.commands.delete(path.toString());
this.uncachePath(path);
}

this.commandUnregistered.Fire(command);
this.logger.debug(`Unregistered command: ${command.getPath()}`);
}
Expand All @@ -267,7 +270,12 @@ export abstract class BaseRegistry<
*/
unregisterGroup(path: RegistryPath) {
const group = this.getGroup(path);
this.logger.assert(group !== undefined, `Group not found: ${path}`);
this.logger.assert(group !== undefined, `Group is not registered: ${path}`);

const parentGroup = this.getGroup(path.parent());
if (parentGroup !== undefined) {
parentGroup.removeGroup(group);
}

for (const command of group.getCommands()) {
this.unregisterCommand(command.getPath());
Expand Down

0 comments on commit 41411af

Please sign in to comment.