6
6
import DOM = require( 'vs/base/browser/dom' ) ;
7
7
import lifecycle = require( 'vs/base/common/lifecycle' ) ;
8
8
import nls = require( 'vs/nls' ) ;
9
+ import os = require( 'os' ) ;
9
10
import platform = require( 'vs/base/common/platform' ) ;
10
11
import xterm = require( 'xterm' ) ;
11
12
import { Dimension } from 'vs/base/browser/builder' ;
@@ -15,6 +16,9 @@ import {ITerminalProcess, ITerminalService} from 'vs/workbench/parts/terminal/el
15
16
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace' ;
16
17
17
18
export class TerminalInstance {
19
+
20
+ private static eolRegex = / \r ? \n / g;
21
+
18
22
private isExiting : boolean = false ;
19
23
20
24
private toDispose : lifecycle . IDisposable [ ] ;
@@ -45,7 +49,7 @@ export class TerminalInstance {
45
49
this . xterm . on ( 'data' , ( data ) => {
46
50
this . terminalProcess . process . send ( {
47
51
event : 'input' ,
48
- data : data
52
+ data : this . sanitizeInput ( data )
49
53
} ) ;
50
54
return false ;
51
55
} ) ;
@@ -84,6 +88,10 @@ export class TerminalInstance {
84
88
this . parentDomElement . appendChild ( this . wrapperElement ) ;
85
89
}
86
90
91
+ private sanitizeInput ( data : any ) {
92
+ return typeof data === 'string' ? data . replace ( TerminalInstance . eolRegex , os . EOL ) : data ;
93
+ }
94
+
87
95
public layout ( dimension : Dimension ) : void {
88
96
if ( ! this . font || ! this . font . charWidth || ! this . font . charHeight ) {
89
97
return ;
0 commit comments