提交 c744fb7a 编写于 作者: D Daniel Imms 提交者: GitHub

Merge pull request #25243 from Microsoft/tyriar/22887

Fix some windows terminal new line issues
...@@ -43,7 +43,7 @@ class StandardTerminalProcessFactory implements ITerminalProcessFactory { ...@@ -43,7 +43,7 @@ class StandardTerminalProcessFactory implements ITerminalProcessFactory {
} }
export class TerminalInstance implements ITerminalInstance { export class TerminalInstance implements ITerminalInstance {
private static readonly EOL_REGEX = /\r?\n/g; private static readonly WINDOWS_EOL_REGEX = /\r?\n/g;
private static _terminalProcessFactory: ITerminalProcessFactory = new StandardTerminalProcessFactory(); private static _terminalProcessFactory: ITerminalProcessFactory = new StandardTerminalProcessFactory();
private static _lastKnownDimensions: Dimension = null; private static _lastKnownDimensions: Dimension = null;
...@@ -365,8 +365,9 @@ export class TerminalInstance implements ITerminalInstance { ...@@ -365,8 +365,9 @@ export class TerminalInstance implements ITerminalInstance {
} }
public sendText(text: string, addNewLine: boolean): void { public sendText(text: string, addNewLine: boolean): void {
if (addNewLine && text.substr(text.length - os.EOL.length) !== os.EOL) { text = this._sanitizeInput(text);
text += os.EOL; if (addNewLine && text.substr(text.length - 1) !== '\r') {
text += '\r';
} }
this._process.send({ this._process.send({
event: 'input', event: 'input',
...@@ -423,7 +424,7 @@ export class TerminalInstance implements ITerminalInstance { ...@@ -423,7 +424,7 @@ export class TerminalInstance implements ITerminalInstance {
} }
private _sanitizeInput(data: any) { private _sanitizeInput(data: any) {
return typeof data === 'string' ? data.replace(TerminalInstance.EOL_REGEX, os.EOL) : data; return typeof data === 'string' ? data.replace(TerminalInstance.WINDOWS_EOL_REGEX, '\r') : data;
} }
protected _getCwd(shell: IShellLaunchConfig, workspace: IWorkspace): string { protected _getCwd(shell: IShellLaunchConfig, workspace: IWorkspace): string {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册