1
0
mirror of https://github.com/winscp/winscp.git synced 2026-10-24 02:28:55 +03:00

Bug 1951: When opening or switching to a session whose local directory does not exist, open the nearest existing parent directory

https://winscp.net/tracker/1951
(cherry picked from commit 10aa9e9018)

# Conflicts:
#	source/forms/ScpCommander.cpp

Source commit: cc258beb565c161b003fb845b10753c364a1ceea
This commit is contained in:
Martin Prikryl
2021-02-04 09:00:56 +00:00
parent e757f7b77b
commit 58303ecfb9
2 changed files with 28 additions and 0 deletions

View File

@@ -545,6 +545,10 @@ void __fastcall TScpCommanderForm::TerminalChanged(bool Replaced)
{
Terminal->ShowExtendedException(&E);
}
else
{
ALocalDirView->OpenFallbackPath(LocalDirectory);
}
}
}
}

View File

@@ -270,6 +270,7 @@ type
function ItemFileName(Item: TListItem): string; override;
function ItemFileSize(Item: TListItem): Int64; override;
function ItemFileTime(Item: TListItem; var Precision: TDateTimePrecision): TDateTime; override;
procedure OpenFallbackPath(Value: string);
{Thread handling: }
procedure StartWatchThread;
@@ -970,6 +971,29 @@ begin
end;
end;
procedure TDirView.OpenFallbackPath(Value: string);
var
APath: string;
begin
while True do
begin
APath := ExtractFileDir(Value);
if (APath = '') or (APath = Value) then
begin
Break;
end
else
begin
try
Path := APath;
Break;
except
Value := APath;
end;
end;
end;
end;
procedure TDirView.SetLoadEnabled(Value: Boolean);
begin
if Value <> LoadEnabled then