@@ -35,5 +35,35 @@ public void CanResolveWorkspaceRelativePath()
35
35
Assert . Equal ( @"..\PeerPath\FilePath.ps1" , workspace . GetRelativePath ( testPathOutside ) ) ;
36
36
Assert . Equal ( testPathAnotherDrive , workspace . GetRelativePath ( testPathAnotherDrive ) ) ;
37
37
}
38
+
39
+ [ Fact ]
40
+ public void CanDetermineIsPathInMemory ( )
41
+ {
42
+ var tempDir = Environment . GetEnvironmentVariable ( "TEMP" ) ;
43
+
44
+ var shortDirPath = Path . Combine ( tempDir , "GitHub" , "PowerShellEditorServices" ) ;
45
+ var shortFilePath = Path . Combine ( shortDirPath , "foo.ps1" ) ;
46
+ var shortDirUriForm = new Uri ( shortDirPath ) . ToString ( ) ;
47
+ var shortFileUriForm = new Uri ( shortFilePath ) . ToString ( ) ;
48
+
49
+ // Test short file absolute paths
50
+ Assert . False ( Workspace . IsPathInMemory ( shortDirPath ) ) ;
51
+ Assert . False ( Workspace . IsPathInMemory ( shortFilePath ) ) ;
52
+ Assert . False ( Workspace . IsPathInMemory ( shortDirUriForm ) ) ;
53
+ Assert . False ( Workspace . IsPathInMemory ( shortFileUriForm ) ) ;
54
+
55
+ // Test short file relative paths - not sure we'll ever get these but just in case
56
+ Assert . False ( Workspace . IsPathInMemory ( "foo.ps1" ) ) ;
57
+ Assert . False ( Workspace . IsPathInMemory ( ".." + Path . DirectorySeparatorChar + "foo.ps1" ) ) ;
58
+
59
+ // Test short non-file paths
60
+ Assert . True ( Workspace . IsPathInMemory ( "untitled:untitled-1" ) ) ;
61
+ var shortUriForm = "git:/c%3A/Users/Keith/GitHub/dahlbyk/posh-git/src/PoshGitTypes.ps1?%7B%22path%22%3A%22c%3A%5C%5CUsers%5C%5CKeith%5C%5CGitHub%5C%5Cdahlbyk%5C%5Cposh-git%5C%5Csrc%5C%5CPoshGitTypes.ps1%22%2C%22ref%22%3A%22~%22%7D" ;
62
+ Assert . True ( Workspace . IsPathInMemory ( shortUriForm ) ) ;
63
+
64
+ // Test long non-file path - known to have crashed PSES
65
+ var longUriForm = "gitlens-git:c%3A%5CUsers%5CKeith%5CGitHub%5Cdahlbyk%5Cposh-git%5Csrc%5CPoshGitTypes%3Ae0022701.ps1?%7B%22fileName%22%3A%22src%2FPoshGitTypes.ps1%22%2C%22repoPath%22%3A%22c%3A%2FUsers%2FKeith%2FGitHub%2Fdahlbyk%2Fposh-git%22%2C%22sha%22%3A%22e0022701fa12e0bc22d0458673d6443c942b974a%22%7D" ;
66
+ Assert . True ( Workspace . IsPathInMemory ( longUriForm ) ) ;
67
+ }
38
68
}
39
69
}
0 commit comments