File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
src/providers/FileSystemProvider Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,18 @@ export function generateFileContent(
7070 sourceContent : Uint8Array
7171) : { content : string [ ] ; enc : boolean ; eol : vscode . EndOfLine } {
7272 const sourceLines = sourceContent . length ? new TextDecoder ( ) . decode ( sourceContent ) . split ( "\n" ) : [ ] ;
73- const eol = sourceLines . length && sourceLines [ 0 ] . slice ( - 1 ) == "\r" ? vscode . EndOfLine . CRLF : vscode . EndOfLine . LF ;
73+
74+ // Detect eol style (a return value), and if CRLF then strip the \r character from end of source lines
75+ let eol = vscode . EndOfLine . LF ;
76+ if ( sourceLines . length && sourceLines [ 0 ] . slice ( - 1 ) == "\r" ) {
77+ eol = vscode . EndOfLine . CRLF ;
78+ for ( let i = 0 ; i < sourceLines . length ; i ++ ) {
79+ if ( sourceLines [ i ] . slice ( - 1 ) == "\r" ) {
80+ sourceLines [ i ] = sourceLines [ i ] . slice ( 0 , - 1 ) ;
81+ }
82+ }
83+ }
84+
7485 const fileExt = fileName . split ( "." ) . pop ( ) . toLowerCase ( ) ;
7586 const csp = fileName . startsWith ( "/" ) ;
7687 if ( fileExt === "cls" && ! csp ) {
You can’t perform that action at this time.
0 commit comments