FIX: Navigate to correct file source when opening path from command line

This commit is contained in:
Lior Lahav 2026-05-31 12:27:30 +03:00
commit 6ffb9f51cd
2 changed files with 16 additions and 4 deletions

View file

@ -176,7 +176,9 @@ end;
function TWinNetFileSource.IsNetworkPath(const Path: String): Boolean;
begin
Result:= (NumCountChars(PathDelim, ExcludeTrailingPathDelimiter(Path)) < 3);
Result:= (Path = PathDelim) or
((Pos(PathDelim + PathDelim, Path) = 1) and
(NumCountChars(PathDelim, ExcludeTrailingPathDelimiter(Path)) < 3));
end;
function TWinNetFileSource.SetCurrentWorkingDirectory(NewDir: String): Boolean;

View file

@ -6364,18 +6364,28 @@ end;
procedure TfrmMain.LoadTabsCommandLine(Params: TCommandLineParams);
procedure LoadPanel(aNoteBook: TFileViewNotebook; aPath: String);
var
AFileView: TFileView;
begin
if Length(aPath) <> 0 then
begin
aPath:= ReplaceEnvVars(ReplaceTilde(aPath));
if not mbFileSystemEntryExists(aPath) then
if not mbFileSystemEntryExists(aPath) and (Pos('\\', aPath) <> 1) then
aPath:= GetDeepestExistingPath(aPath);
if Length(aPath) <> 0 then
begin
if Params.NewTab then
AddTab(aNoteBook, aPath)
else
aNoteBook.ActivePage.FileView.ChangePathAndSetActiveFile(aPath)
else begin
AFileView:= aNoteBook.ActivePage.FileView;
if mbFileExists(aPath) then
begin
if ChooseFileSource(AFileView, ExtractFileDir(aPath)) then
AFileView.SetActiveFile(ExtractFileName(aPath));
end
else
ChooseFileSource(AFileView, aPath);
end;
end;
end;
end;