File tree 1 file changed +7
-20
lines changed
src/PowerShellEditorServices/Workspace
1 file changed +7
-20
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,12 @@ public class ScriptFile
20
20
{
21
21
#region Private Fields
22
22
23
+ private static readonly string [ ] s_newlines = new [ ]
24
+ {
25
+ "\n " ,
26
+ "\r \n "
27
+ } ;
28
+
23
29
private Token [ ] scriptTokens ;
24
30
private Version powerShellVersion ;
25
31
@@ -215,26 +221,7 @@ internal static List<string> GetLinesInternal(string text)
215
221
throw new ArgumentNullException ( nameof ( text ) ) ;
216
222
}
217
223
218
- // ReadLine returns null immediately for empty string, so special case it.
219
- if ( text . Length == 0 )
220
- {
221
- return new List < string > { string . Empty } ;
222
- }
223
-
224
- using ( var reader = new StringReader ( text ) )
225
- {
226
- // 50 is a rough guess for typical average line length, this saves some list
227
- // resizes in the common case and does not hurt meaningfully if we're wrong.
228
- var list = new List < string > ( text . Length / 50 ) ;
229
- string line ;
230
-
231
- while ( ( line = reader . ReadLine ( ) ) != null )
232
- {
233
- list . Add ( line ) ;
234
- }
235
-
236
- return list ;
237
- }
224
+ return new List < string > ( text . Split ( s_newlines , StringSplitOptions . None ) ) ;
238
225
}
239
226
240
227
/// <summary>
You can’t perform that action at this time.
0 commit comments