From 2e9344f8b71e07bd93fa99f8d51b7e4e312b69fa Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Mon, 5 Dec 2022 12:16:42 +0100 Subject: [PATCH] #7588 - serialized command execution --- tabby-core/src/services/commands.service.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tabby-core/src/services/commands.service.ts b/tabby-core/src/services/commands.service.ts index 64fa78d7..9ae33694 100644 --- a/tabby-core/src/services/commands.service.ts +++ b/tabby-core/src/services/commands.service.ts @@ -4,6 +4,8 @@ import { SelectorService } from './selector.service' @Injectable({ providedIn: 'root' }) export class CommandService { + private lastCommand = Promise.resolve() + constructor ( private selector: SelectorService, private config: ConfigService, @@ -68,7 +70,17 @@ export class CommandService { commands.push(...await provider.provide(context)) } - return commands.sort((a, b) => (a.weight ?? 0) - (b.weight ?? 0)) + return commands + .sort((a, b) => (a.weight ?? 0) - (b.weight ?? 0)) + .map(command => { + const run = command.run + command.run = async () => { + // Serialize execution + this.lastCommand = this.lastCommand.finally(run) + await this.lastCommand + } + return command + }) } async run (id: string, context: CommandContext): Promise {