File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed
src/PowerShellEditorServices/Workspace Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -192,6 +192,21 @@ public ScriptFile (
192192
193193 #region Public Methods
194194
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+
195210 /// <summary>
196211 /// Gets a line from the file's contents.
197212 /// </summary>
@@ -479,11 +494,7 @@ private void SetFileContents(string fileContents)
479494 {
480495 // Split the file contents into lines and trim
481496 // 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 ( ) ;
487498
488499 // Parse the contents to get syntax tree and errors
489500 this . ParseFileContents ( ) ;
You can’t perform that action at this time.
0 commit comments