You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Adopt virtual process terminals in task custom execution API #76492
/** * Class used to execute an extension callback as a task. */exportclassCustomExecution2{/** * @param process The [TerminalVirtualProcess](#TerminalVirtualProcess) to be used by the task to display output. * @param callback The callback that will be called when the task is started by a user. */constructor(process: TerminalVirtualProcess,callback: (thisArg?: any)=>Thenable<void>);/** * The callback used to execute the task. Cancellation should be handled using the [TerminalVirtualProcess](#TerminalVirtualProcess). * When the task is complete, onDidExit should be fired on the TerminalVirtualProcess with the exit code with '0' for success and a non-zero value for failure. */callback: (thisArg?: any)=>Thenable<void>;/** * The [TerminalVirtualProcess](#TerminalVirtualProcess) will be attached to a terminal when the task is started. * At that point it can be used to show output and accept input. process.shutdown() should be implemented to handle interruption of the task */process: TerminalVirtualProcess;}
/** * Class used to execute an extension callback as a task. */exportclassCustomExecution2{/** * @param process The [TerminalVirtualProcess](#TerminalVirtualProcess) to be used by the task to display output. * @param callback The callback that will be called when the task is started by a user. */constructor(callback: (thisArg?: any)=>Thenable<TerminalVirtualProcess>);/** * The callback used to execute the task. Cancellation should be handled using the shutdown method of [TerminalVirtualProcess](#TerminalVirtualProcess). * When the task is complete, onDidExit should be fired on the TerminalVirtualProcess with the exit code with '0' for success and a non-zero value for failure. */callback: (thisArg?: any)=>Thenable<TerminalVirtualProcess>;}
This also requires a start on the TerminalVirtualProcess because:
constexecution=newvscode.CustomExecution2(async(): Promise<vscode.TerminalVirtualProcess>=>{returnnewTestTerminalProcess();});
...
classTestTerminalProcessimplementsvscode.TerminalVirtualProcess{privatewriteEmitter=newvscode.EventEmitter<string>();onDidWrite=this.writeEmitter.event;privateexitEmitter=newvscode.EventEmitter<number>();onDidExit=this.exitEmitter.event;constructor(){// Can't start emitting things here, no one is listening. }start(){this.writeEmitter.fire('Hello, terminal');setTimeout(()=>{this.writeEmitter.fire('Goodbye!');this.exitEmitter.fire(0);},3000);}shutdown(){console.log("Shutting down");}input(data: string): void{console.log('There was input');}setDimensions?(dimensions: vscode.TerminalDimensions): void{console.log('Dims changed');}}
Activity
alexr00 commentedon Jul 8, 2019
alexr00 commentedon Jul 9, 2019
Updated API:
This also requires a
starton theTerminalVirtualProcessbecause:I've added the
startin the PR: 83c08e4Adopt TerminalVirtualProcess for Custom task execution (#76852)