提交 fcd65cc8 编写于 作者: D Daniel Imms

Ensure terminal pty is ready before sendText is called

Fixes #27939
上级 6a01ff48
...@@ -31,6 +31,7 @@ import { TerminalLinkHandler } from 'vs/workbench/parts/terminal/electron-browse ...@@ -31,6 +31,7 @@ import { TerminalLinkHandler } from 'vs/workbench/parts/terminal/electron-browse
import { TerminalWidgetManager } from 'vs/workbench/parts/terminal/browser/terminalWidgetManager'; import { TerminalWidgetManager } from 'vs/workbench/parts/terminal/browser/terminalWidgetManager';
import { registerThemingParticipant, ITheme, ICssStyleCollector } from 'vs/platform/theme/common/themeService'; import { registerThemingParticipant, ITheme, ICssStyleCollector } from 'vs/platform/theme/common/themeService';
import { scrollbarSliderBackground, scrollbarSliderHoverBackground, scrollbarSliderActiveBackground } from 'vs/platform/theme/common/colorRegistry'; import { scrollbarSliderBackground, scrollbarSliderHoverBackground, scrollbarSliderActiveBackground } from 'vs/platform/theme/common/colorRegistry';
import { TPromise } from "vs/base/common/winjs.base";
/** The amount of time to consider terminal errors to be related to the launch */ /** The amount of time to consider terminal errors to be related to the launch */
const LAUNCHING_DURATION = 500; const LAUNCHING_DURATION = 500;
...@@ -56,6 +57,7 @@ export class TerminalInstance implements ITerminalInstance { ...@@ -56,6 +57,7 @@ export class TerminalInstance implements ITerminalInstance {
private _hadFocusOnExit: boolean; private _hadFocusOnExit: boolean;
private _isLaunching: boolean; private _isLaunching: boolean;
private _isVisible: boolean; private _isVisible: boolean;
private _processReady: TPromise<void>;
private _isDisposed: boolean; private _isDisposed: boolean;
private _onDisposed: Emitter<ITerminalInstance>; private _onDisposed: Emitter<ITerminalInstance>;
private _onDataForApi: Emitter<{ instance: ITerminalInstance, data: string }>; private _onDataForApi: Emitter<{ instance: ITerminalInstance, data: string }>;
...@@ -115,6 +117,11 @@ export class TerminalInstance implements ITerminalInstance { ...@@ -115,6 +117,11 @@ export class TerminalInstance implements ITerminalInstance {
this._onProcessIdReady = new Emitter<TerminalInstance>(); this._onProcessIdReady = new Emitter<TerminalInstance>();
this._onTitleChanged = new Emitter<string>(); this._onTitleChanged = new Emitter<string>();
// Create a promise that resolves when the pty is ready
this._processReady = new TPromise<void>(c => {
this.onProcessIdReady(() => c(void 0));
});
this._initDimensions(); this._initDimensions();
this._createProcess(this._contextService.getWorkspace(), this._shellLaunchConfig); this._createProcess(this._contextService.getWorkspace(), this._shellLaunchConfig);
this._createXterm(); this._createXterm();
...@@ -376,6 +383,7 @@ export class TerminalInstance implements ITerminalInstance { ...@@ -376,6 +383,7 @@ export class TerminalInstance implements ITerminalInstance {
} }
public sendText(text: string, addNewLine: boolean): void { public sendText(text: string, addNewLine: boolean): void {
this._processReady.then(() => {
text = this._sanitizeInput(text); text = this._sanitizeInput(text);
if (addNewLine && text.substr(text.length - 1) !== '\r') { if (addNewLine && text.substr(text.length - 1) !== '\r') {
text += '\r'; text += '\r';
...@@ -384,6 +392,7 @@ export class TerminalInstance implements ITerminalInstance { ...@@ -384,6 +392,7 @@ export class TerminalInstance implements ITerminalInstance {
event: 'input', event: 'input',
data: text data: text
}); });
});
} }
public setVisible(visible: boolean): void { public setVisible(visible: boolean): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册