Skip to content

Commit e7f8161

Browse files
committed
trim leading slash in file path
1 parent 9c4bae4 commit e7f8161

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

GitContentSearch.UI/ViewModels/MainWindowViewModel.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ private async Task HandleFilePathLostFocusAsync()
4141
try
4242
{
4343
var processWrapper = new ProcessWrapper();
44-
var absolutePath = Path.IsPathRooted(FilePath)
45-
? FilePath
46-
: Path.GetFullPath(Path.Combine(WorkingDirectory, FilePath));
44+
// Trim leading slash if present, as it's meant to be relative to the git repository
45+
var normalizedPath = FilePath.TrimStart('/');
46+
var absolutePath = Path.IsPathRooted(normalizedPath)
47+
? normalizedPath
48+
: Path.GetFullPath(Path.Combine(WorkingDirectory, normalizedPath));
4749

4850
var directoryPath = Path.GetDirectoryName(absolutePath);
4951
if (string.IsNullOrEmpty(directoryPath) || !Directory.Exists(directoryPath))

0 commit comments

Comments
 (0)