@@ -30,10 +30,11 @@ export class InlineEditsInsertionView extends Disposable implements IInlineEdits
30
30
if ( ! state ) { return undefined ; }
31
31
32
32
const textModel = this . _editor . getModel ( ) ! ;
33
+ const eol = textModel . getEOL ( ) ;
33
34
34
- if ( state . startColumn === 1 && state . lineNumber > 1 && textModel . getLineLength ( state . lineNumber ) !== 0 && state . text . endsWith ( '\n' ) && ! state . text . startsWith ( '\n' ) ) {
35
+ if ( state . startColumn === 1 && state . lineNumber > 1 && textModel . getLineLength ( state . lineNumber ) !== 0 && state . text . endsWith ( eol ) && ! state . text . startsWith ( eol ) ) {
35
36
const endOfLineColumn = textModel . getLineLength ( state . lineNumber - 1 ) + 1 ;
36
- return { lineNumber : state . lineNumber - 1 , column : endOfLineColumn , text : '\n' + state . text . slice ( 0 , - 1 ) } ;
37
+ return { lineNumber : state . lineNumber - 1 , column : endOfLineColumn , text : eol + state . text . slice ( 0 , - eol . length ) } ;
37
38
}
38
39
39
40
return { lineNumber : state . lineNumber , column : state . startColumn , text : state . text } ;
@@ -88,12 +89,12 @@ export class InlineEditsInsertionView extends Disposable implements IInlineEdits
88
89
}
89
90
this . _editorObs . versionId . read ( reader ) ;
90
91
const textModel = this . _editor . getModel ( ) ! ;
92
+ const eol = textModel . getEOL ( ) ;
91
93
92
- const cleanText = state . text . replace ( '\r\n' , '\n' ) ;
93
- const textBeforeInsertion = cleanText . startsWith ( '\n' ) ? '' : textModel . getValueInRange ( new Range ( state . lineNumber , 1 , state . lineNumber , state . column ) ) ;
94
+ const textBeforeInsertion = state . text . startsWith ( eol ) ? '' : textModel . getValueInRange ( new Range ( state . lineNumber , 1 , state . lineNumber , state . column ) ) ;
94
95
const textAfterInsertion = textModel . getValueInRange ( new Range ( state . lineNumber , state . column , state . lineNumber , textModel . getLineLength ( state . lineNumber ) + 1 ) ) ;
95
- const text = textBeforeInsertion + cleanText + textAfterInsertion ;
96
- const lines = text . split ( '\n' ) ;
96
+ const text = textBeforeInsertion + state . text + textAfterInsertion ;
97
+ const lines = text . split ( eol ) ;
97
98
98
99
const renderOptions = RenderOptions . fromEditor ( this . _editor ) . withSetWidth ( false ) ;
99
100
const lineWidths = lines . map ( line => {
@@ -121,15 +122,16 @@ export class InlineEditsInsertionView extends Disposable implements IInlineEdits
121
122
122
123
// Adjust for leading/trailing newlines
123
124
const lineHeight = this . _editor . getOption ( EditorOption . lineHeight ) ;
125
+ const eol = this . _editor . getModel ( ) ! . getEOL ( ) ;
124
126
let topTrim = 0 ;
125
127
let bottomTrim = 0 ;
126
128
127
129
let i = 0 ;
128
- for ( ; i < text . length && text [ i ] === '\n' ; i ++ ) {
130
+ for ( ; i < text . length && text . startsWith ( eol , i ) ; i += eol . length ) {
129
131
topTrim += lineHeight ;
130
132
}
131
133
132
- for ( let j = text . length - 1 ; j > i && text [ j ] === '\n' ; j -- ) {
134
+ for ( let j = text . length ; j > i && text . endsWith ( eol , j ) ; j -= eol . length ) {
133
135
bottomTrim += lineHeight ;
134
136
}
135
137
0 commit comments