mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
parent
2c28cd7185
commit
1a6f5b638c
|
@ -824,10 +824,29 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
|
|||
}
|
||||
|
||||
async runCommand(commandLine: string, shouldExecute: boolean): Promise<void> {
|
||||
let commandDetection = this.capabilities.get(TerminalCapability.CommandDetection);
|
||||
|
||||
// Await command detection if the terminal is starting up
|
||||
if (!commandDetection && (this._processManager.processState === ProcessState.Uninitialized || this._processManager.processState === ProcessState.Launching)) {
|
||||
const store = new DisposableStore();
|
||||
await Promise.race([
|
||||
new Promise<void>(r => {
|
||||
store.add(this.capabilities.onDidAddCapabilityType(e => {
|
||||
if (e === TerminalCapability.CommandDetection) {
|
||||
commandDetection = this.capabilities.get(TerminalCapability.CommandDetection);
|
||||
r();
|
||||
}
|
||||
}));
|
||||
}),
|
||||
timeout(2000),
|
||||
]);
|
||||
store.dispose();
|
||||
}
|
||||
|
||||
// Determine whether to send ETX (ctrl+c) before running the command. This should always
|
||||
// happen unless command detection can reliably say that a command is being entered and
|
||||
// there is no content in the prompt
|
||||
if (this.capabilities.get(TerminalCapability.CommandDetection)?.hasInput !== false) {
|
||||
if (commandDetection?.hasInput !== false) {
|
||||
await this.sendText('\x03', false);
|
||||
// Wait a little before running the command to avoid the sequences being echoed while the ^C
|
||||
// is being evaluated
|
||||
|
|
Loading…
Reference in a new issue