mirror of
https://github.com/winscp/winscp.git
synced 2026-10-24 02:28:55 +03:00
Bug 1891: Correct letter case variant of remote directory in directory tree was not always selected
https://winscp.net/tracker/1891 Source commit: ef7c94034eaa43964a021298eb0e93017730fd19
This commit is contained in:
@@ -777,7 +777,8 @@ TTreeNode * __fastcall TCustomUnixDriveView::FindNodeToPath(UnicodeString Path)
|
||||
{
|
||||
UnicodeString DirName = UnixExtractFileName(Path);
|
||||
int StartIndex = 0;
|
||||
int EndIndex = Parent->Count - 1;
|
||||
int LastIndex = Parent->Count - 1;
|
||||
int EndIndex = LastIndex;
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -786,6 +787,20 @@ TTreeNode * __fastcall TCustomUnixDriveView::FindNodeToPath(UnicodeString Path)
|
||||
int C = DoCompareText(DirName, NodeDir);
|
||||
if (C == 0)
|
||||
{
|
||||
// In case there are more items that are case insensitivelly or logically equivalent,
|
||||
// walk back to find the first such one and then walk forward through all such items,
|
||||
// looking for an exact binary match.
|
||||
// If so such match is found (can it even happen?), return the last equivalent item.
|
||||
while ((Index > 0) && (DoCompareText(DirName, Parent->Item[Index - 1]->Text) == 0))
|
||||
{
|
||||
Index--;
|
||||
}
|
||||
while (!SameStr(DirName, Parent->Item[Index]->Text) &&
|
||||
(Index < LastIndex) &&
|
||||
(DoCompareText(DirName, Parent->Item[Index + 1]->Text) == 0))
|
||||
{
|
||||
Index++;
|
||||
}
|
||||
Result = Parent->Item[Index];
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user