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)
195
195
}
196
196
197
197
/// <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"
199
199
/// which has not been saved to file.
200
200
/// </summary>
201
201
/// <param name="path">The path to check.</param>
202
202
/// <returns>True if the path is an untitled file, false otherwise.</returns>
203
203
internal static bool IsUntitledPath ( string path )
204
204
{
205
205
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 ) ;
210
209
}
211
210
212
211
/// <summary>
Original file line number Diff line number Diff line change @@ -651,6 +651,7 @@ public void DocumentUriReturnsCorrectStringForAbsolutePath()
651
651
[ InlineData ( "vscode-notebook-cell:/Users/me/Documents/test.ps1#0001" , true ) ]
652
652
[ InlineData ( "https://microsoft.com" , true ) ]
653
653
[ InlineData ( "Untitled:Untitled-1" , true ) ]
654
+ [ InlineData ( "'a log statement' > 'c:\\ Users\\ me\\ Documents\\ test.txt'\r \n " , false ) ]
654
655
public void IsUntitledFileIsCorrect ( string path , bool expected ) => Assert . Equal ( expected , ScriptFile . IsUntitledPath ( path ) ) ;
655
656
}
656
657
}
You can’t perform that action at this time.
0 commit comments