mirror of
https://github.com/Eugeny/tabby.git
synced 2025-04-12 16:10:26 +08:00
#7588 - serialized command execution
This commit is contained in:
parent
98476df882
commit
2e9344f8b7
@ -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<void> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user