mirror of
https://github.com/Eugeny/tabby.git
synced 2025-09-12 19:34:34 +00:00
#7588 - serialized command execution
This commit is contained in:
@@ -4,6 +4,8 @@ import { SelectorService } from './selector.service'
|
|||||||
|
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class CommandService {
|
export class CommandService {
|
||||||
|
private lastCommand = Promise.resolve()
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private selector: SelectorService,
|
private selector: SelectorService,
|
||||||
private config: ConfigService,
|
private config: ConfigService,
|
||||||
@@ -68,7 +70,17 @@ export class CommandService {
|
|||||||
commands.push(...await provider.provide(context))
|
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<void> {
|
async run (id: string, context: CommandContext): Promise<void> {
|
||||||
|
Reference in New Issue
Block a user