File tree Expand file tree Collapse file tree 1 file changed +10
-24
lines changed
src/Razor/Microsoft.AspNetCore.Razor.Language/src Expand file tree Collapse file tree 1 file changed +10
-24
lines changed Original file line number Diff line number Diff line change @@ -75,45 +75,31 @@ private int[] GetLineStarts()
75
75
// We always consider a document to have at least a 0th line, even if it's empty.
76
76
starts . Add ( 0 ) ;
77
77
78
- var unprocessedCR = false ;
79
-
80
- // Length - 1 because we don't care if there was a linebreak as the last character.
81
78
var length = _document . Length ;
82
- for ( var i = 0 ; i < length - 1 ; i ++ )
79
+ for ( var i = 0 ; i < length ; i ++ )
83
80
{
84
81
var c = _document [ i ] ;
85
- var isLineBreak = false ;
86
82
87
83
switch ( c )
88
84
{
89
85
case '\r ' :
90
- unprocessedCR = true ;
91
- continue ;
86
+ if ( i + 1 < length && _document [ i + 1 ] == '\n ' )
87
+ {
88
+ i ++ ;
89
+ }
90
+
91
+ starts . Add ( i + 1 ) ;
92
+ break ;
92
93
93
94
case '\n ' :
94
- unprocessedCR = false ;
95
- isLineBreak = true ;
95
+ starts . Add ( i + 1 ) ;
96
96
break ;
97
97
98
98
case '\u0085 ' :
99
99
case '\u2028 ' :
100
100
case '\u2029 ' :
101
- isLineBreak = true ;
101
+ starts . Add ( i + 1 ) ;
102
102
break ;
103
-
104
- }
105
-
106
- if ( unprocessedCR )
107
- {
108
- // If we get here it means that we had a CR followed by something other than an LF.
109
- // Add the CR as a line break.
110
- starts . Add ( i ) ;
111
- unprocessedCR = false ;
112
- }
113
-
114
- if ( isLineBreak )
115
- {
116
- starts . Add ( i + 1 ) ;
117
103
}
118
104
}
119
105
You can’t perform that action at this time.
0 commit comments