Skip to content

Commit 0746df2

Browse files
Fix IsUntitledPath logic (#1332)
1 parent 7790609 commit 0746df2

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/PowerShellEditorServices/Services/TextDocument/ScriptFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ internal static List<string> GetLinesInternal(string text)
217217
internal static bool IsUntitledPath(string path)
218218
{
219219
Validate.IsNotNull(nameof(path), path);
220-
return string.Equals(
220+
return !string.Equals(
221221
DocumentUri.From(path).Scheme,
222222
Uri.UriSchemeFile,
223223
StringComparison.OrdinalIgnoreCase);

test/PowerShellEditorServices.Test/Session/ScriptFileTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,5 +658,17 @@ public void DocumentUriRetunsCorrectStringForAbsolutePath()
658658
Assert.Equal("file:///home/JamesHolden/projects/Rocinate/Proto%3AMole%5Ccule.ps1", scriptFile.DocumentUri);
659659
}
660660
}
661+
662+
[Trait("Category", "ScriptFile")]
663+
[Theory]
664+
[InlineData("C:\\Users\\me\\Documents\\test.ps1", false)]
665+
[InlineData("/Users/me/Documents/test.ps1", false)]
666+
[InlineData("vscode-notebook-cell:/Users/me/Documents/test.ps1#0001", true)]
667+
[InlineData("https://microsoft.com", true)]
668+
[InlineData("Untitled:Untitled-1", true)]
669+
public void IsUntitledFileIsCorrect(string path, bool expected)
670+
{
671+
Assert.Equal(expected, ScriptFile.IsUntitledPath(path));
672+
}
661673
}
662674
}

0 commit comments

Comments
 (0)