mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-31 09:10:30 -04:00
Merge from vscode 1fbacccbc900bb59ba8a8f26a4128d48a1c97842
This commit is contained in:
@@ -10,6 +10,7 @@ import { Terminal as XTermTerminal } from 'xterm';
|
||||
import * as WindowsProcessTreeType from 'windows-process-tree';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { ITerminalInstance, TerminalShellType, WindowsShellType } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
|
||||
const SHELL_EXECUTABLES = [
|
||||
'cmd.exe',
|
||||
@@ -46,36 +47,40 @@ export class WindowsShellHelper extends Disposable implements IWindowsShellHelpe
|
||||
|
||||
this._isDisposed = false;
|
||||
|
||||
(import('windows-process-tree')).then(mod => {
|
||||
if (this._isDisposed) {
|
||||
return;
|
||||
}
|
||||
this._startMonitoringShell();
|
||||
}
|
||||
|
||||
windowsProcessTree = mod;
|
||||
// The debounce is necessary to prevent multiple processes from spawning when
|
||||
// the enter key or output is spammed
|
||||
Event.debounce(this._onCheckShell.event, (l, e) => e, 150, true)(() => {
|
||||
setTimeout(() => {
|
||||
this.checkShell();
|
||||
}, 50);
|
||||
});
|
||||
private async _startMonitoringShell(): Promise<void> {
|
||||
if (!windowsProcessTree) {
|
||||
windowsProcessTree = await import('windows-process-tree');
|
||||
}
|
||||
|
||||
// We want to fire a new check for the shell on a linefeed, but only
|
||||
// when parsing has finished which is indicated by the cursormove event.
|
||||
// If this is done on every linefeed, parsing ends up taking
|
||||
// significantly longer due to resetting timers. Note that this is
|
||||
// private API.
|
||||
this._xterm.onLineFeed(() => this._newLineFeed = true);
|
||||
this._xterm.onCursorMove(() => {
|
||||
if (this._newLineFeed) {
|
||||
this._onCheckShell.fire(undefined);
|
||||
this._newLineFeed = false;
|
||||
}
|
||||
});
|
||||
if (this._isDisposed) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Fire a new check for the shell when any key is pressed.
|
||||
this._xterm.onKey(() => this._onCheckShell.fire(undefined));
|
||||
// The debounce is necessary to prevent multiple processes from spawning when
|
||||
// the enter key or output is spammed
|
||||
Event.debounce(this._onCheckShell.event, (l, e) => e, 150, true)(async () => {
|
||||
await timeout(50);
|
||||
this.checkShell();
|
||||
});
|
||||
|
||||
// We want to fire a new check for the shell on a linefeed, but only
|
||||
// when parsing has finished which is indicated by the cursormove event.
|
||||
// If this is done on every linefeed, parsing ends up taking
|
||||
// significantly longer due to resetting timers. Note that this is
|
||||
// private API.
|
||||
this._xterm.onLineFeed(() => this._newLineFeed = true);
|
||||
this._xterm.onCursorMove(() => {
|
||||
if (this._newLineFeed) {
|
||||
this._onCheckShell.fire(undefined);
|
||||
this._newLineFeed = false;
|
||||
}
|
||||
});
|
||||
|
||||
// Fire a new check for the shell when any key is pressed.
|
||||
this._xterm.onKey(() => this._onCheckShell.fire(undefined));
|
||||
}
|
||||
|
||||
private checkShell(): void {
|
||||
|
||||
Reference in New Issue
Block a user