File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed
src/PowerShellEditorServices/Services/TextDocument
test/PowerShellEditorServices.Test/Session Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -195,18 +195,17 @@ internal static List<string> GetLinesInternal(string text)
195195 }
196196
197197 /// <summary>
198- /// Deterines whether the supplied path indicates the file is an "untitled:Unitled -X"
198+ /// Determines whether the supplied path indicates the file is an "untitled:Untitled -X"
199199 /// which has not been saved to file.
200200 /// </summary>
201201 /// <param name="path">The path to check.</param>
202202 /// <returns>True if the path is an untitled file, false otherwise.</returns>
203203 internal static bool IsUntitledPath ( string path )
204204 {
205205 Validate . IsNotNull ( nameof ( path ) , path ) ;
206- return ! string . Equals (
207- DocumentUri . From ( path ) . Scheme ,
208- Uri . UriSchemeFile ,
209- StringComparison . OrdinalIgnoreCase ) ;
206+ // This may not have been given a URI, so return false instead of throwing.
207+ return Uri . IsWellFormedUriString ( path , UriKind . RelativeOrAbsolute ) &&
208+ ! string . Equals ( DocumentUri . From ( path ) . Scheme , Uri . UriSchemeFile , StringComparison . OrdinalIgnoreCase ) ;
210209 }
211210
212211 /// <summary>
Original file line number Diff line number Diff line change @@ -651,6 +651,7 @@ public void DocumentUriReturnsCorrectStringForAbsolutePath()
651651 [ InlineData ( "vscode-notebook-cell:/Users/me/Documents/test.ps1#0001" , true ) ]
652652 [ InlineData ( "https://microsoft.com" , true ) ]
653653 [ InlineData ( "Untitled:Untitled-1" , true ) ]
654+ [ InlineData ( "'a log statement' > 'c:\\ Users\\ me\\ Documents\\ test.txt'\r \n " , false ) ]
654655 public void IsUntitledFileIsCorrect ( string path , bool expected ) => Assert . Equal ( expected , ScriptFile . IsUntitledPath ( path ) ) ;
655656 }
656657}
You can’t perform that action at this time.
0 commit comments