File tree 1 file changed +16
-5
lines changed
src/PowerShellEditorServices/Workspace
1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -192,6 +192,21 @@ public ScriptFile (
192
192
193
193
#region Public Methods
194
194
195
+ /// <summary>
196
+ /// Get the lines in a string.
197
+ /// </summary>
198
+ /// <param name="text">Input string to be split up into lines.</param>
199
+ /// <returns>The lines in the string.</returns>
200
+ public static IEnumerable < string > GetLines ( string text )
201
+ {
202
+ if ( text == null )
203
+ {
204
+ throw new ArgumentNullException ( nameof ( text ) ) ;
205
+ }
206
+
207
+ return text . Split ( '\n ' ) . Select ( line => line . TrimEnd ( '\r ' ) ) ;
208
+ }
209
+
195
210
/// <summary>
196
211
/// Gets a line from the file's contents.
197
212
/// </summary>
@@ -479,11 +494,7 @@ private void SetFileContents(string fileContents)
479
494
{
480
495
// Split the file contents into lines and trim
481
496
// any carriage returns from the strings.
482
- this . FileLines =
483
- fileContents
484
- . Split ( '\n ' )
485
- . Select ( line => line . TrimEnd ( '\r ' ) )
486
- . ToList ( ) ;
497
+ this . FileLines = GetLines ( fileContents ) . ToList ( ) ;
487
498
488
499
// Parse the contents to get syntax tree and errors
489
500
this . ParseFileContents ( ) ;
You can’t perform that action at this time.
0 commit comments