Browse Source

Bug 1548: Clicking root folder in path label opens home folder instead of root folder

https://winscp.net/tracker/1548

Source commit: 2c794e08d71233b410e693366309d8b95b5a15d6
Martin Prikryl 8 years ago
parent
commit
76c5b8097e
1 changed files with 6 additions and 1 deletions
  1. 6 1
      source/packages/my/PathLabel.pas

+ 6 - 1
source/packages/my/PathLabel.pas

@@ -198,7 +198,8 @@ begin
     HotPath := HotTrackPath;
     if HotPath <> '' then
     begin
-      if Copy(HotPath, Length(HotPath), 1) = GetSeparator then
+      if (Copy(HotPath, Length(HotPath), 1) = GetSeparator) and
+         (HotPath <> GetSeparator) then
         SetLength(HotPath, Length(HotPath) - 1);
 
       if HotPath = HotTrackMask then DoMaskClick
@@ -210,15 +211,19 @@ begin
         // The below is based on knowledge of MinimizeName algorithm
         RemainingPath := Copy(FDisplayPath, Length(HotPath) + 1,
           Length(FDisplayPath) - Length(HotPath));
+        // Contrary to stripping separator from HotPath above, we strip it even from bare /,
+        // as the Caption does not include it either
         if Copy(RemainingPath, Length(RemainingPath), 1) = GetSeparator then
           SetLength(RemainingPath, Length(RemainingPath) - 1);
 
+        // Part from ellipsis (inclusive)
         if RemainingPath = Copy(Caption, Length(Caption) - Length(RemainingPath) + 1,
              Length(RemainingPath)) then
         begin
           DoPathClick(Copy(Caption, 1, Length(Caption) - Length(RemainingPath)));
         end
           else
+        // Part before ellipsis
         if HotPath = Copy(Caption, 1, Length(HotPath)) then
         begin
           DoPathClick(HotPath);