Sfoglia il codice sorgente

Local-local tab can be renamed

Part of Bug 1893

Source commit: 0490ee2a0f87016f962635648eec8717d05fae9c
Martin Prikryl 4 anni fa
parent
commit
32f3444b60

+ 5 - 3
source/forms/CustomScpExplorer.cpp

@@ -4899,14 +4899,16 @@ void __fastcall TCustomScpExplorerForm::DuplicateSession()
 //---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::RenameSession()
 {
-  UnicodeString Name = Terminal->SessionData->SessionName;
-  if (InputDialog(LoadStr(RENAME_SESSION_TITLE), LoadStr(RENAME_SESSION_PROMPT), Name, HELP_SESSION_RENAME))
+  UnicodeString Name = ManagedSession->SessionData->SessionName;
+  if (InputDialog(LoadStr(RENAME_SESSION_TITLE), LoadStr(RENAME_SESSION_PROMPT), Name, HELP_SESSION_RENAME) &&
+      // When submitting the default name, do not fix it
+      (Name != ManagedSession->SessionData->SessionName))
   {
     // Checks for a slash only, so it's not that big deal that we do the check after submitting the dialog only.
     TSessionData::ValidateName(Name);
 
     // This is inconsistent with how color (for example) is handled.
-    Terminal->SessionData->Name = Name;
+    ManagedSession->SessionData->Name = Name;
 
     UpdateControls();
     // Add/Remove distinguishing paths from sessions of the same name.

+ 1 - 1
source/forms/NonVisual.cpp

@@ -416,7 +416,7 @@ void __fastcall TNonVisualDataModule::ExplorerActionsUpdate(
   UPD(NewSessionAction, true)
   UPD(SiteManagerAction, true)
   UPD(DuplicateTabAction, HasManagedSession)
-  UPD(RenameTabAction, HasTerminal)
+  UPD(RenameTabAction, HasManagedSession)
   UPD(CloseTabAction, HasManagedSession && ScpExplorer->CanCloseSession(ScpExplorer->ManagedSession))
   UPDEX1(DisconnectSessionAction, HasTerminal, DisconnectSessionAction->Visible = (ScpExplorer->Terminal == NULL) || !ScpExplorer->Terminal->Disconnected)
   UPDEX1(ReconnectSessionAction, (ScpExplorer->Terminal != NULL) && ScpExplorer->Terminal->Disconnected, ReconnectSessionAction->Visible = ReconnectSessionAction->Enabled)

+ 3 - 0
source/forms/NonVisual.dfm

@@ -3296,6 +3296,9 @@ object NonVisualDataModule: TNonVisualDataModule
     object TBXItem102: TTBXItem
       Action = DuplicateTabAction
     end
+    object TBXItem103: TTBXItem
+      Action = RenameTabAction
+    end
     object TBXSeparatorItem21: TTBXSeparatorItem
     end
     object TBXItem109: TTBXItem

+ 1 - 0
source/forms/NonVisual.h

@@ -670,6 +670,7 @@ __published:    // IDE-managed Components
   TTBXSeparatorItem *TBXSeparatorItem22;
   TTBXItem *TBXItem110;
   TTBXItem *TBXItem102;
+  TTBXItem *TBXItem103;
   void __fastcall ExplorerActionsUpdate(TBasicAction *Action, bool &Handled);
   void __fastcall ExplorerActionsExecute(TBasicAction *Action, bool &Handled);
   void __fastcall SessionIdleTimerTimer(TObject *Sender);

+ 23 - 15
source/forms/ScpCommander.cpp

@@ -2787,25 +2787,33 @@ void TScpCommanderForm::LocalLocalCopy(
 //---------------------------------------------------------------------------
 UnicodeString TScpCommanderForm::GetLocalBrowserSessionTitle(TManagedTerminal * ASession)
 {
-  DebugAssert(ASession->LocalBrowser);
-  UnicodeString Path1;
-  UnicodeString Path2;
-  TTerminalManager * Manager = TTerminalManager::Instance();
-  if ((ASession == ManagedSession) &&
-      // prevent tab title flicker, when switching to local-local tab, as the path changes in individual local panels
-      !FSessionChanging)
+  UnicodeString Result;
+  if (ASession->SessionData->HasSessionName())
   {
-    Path1 = LocalDirView->PathName;
-    Path2 = OtherLocalDirView->PathName;
+    Result = ASession->SessionData->SessionName;
   }
   else
   {
-    Path1 = ASession->StateData->LocalDirectory;
-    Path2 = ASession->StateData->OtherLocalDirectory;
+    DebugAssert(ASession->LocalBrowser);
+    UnicodeString Path1;
+    UnicodeString Path2;
+    TTerminalManager * Manager = TTerminalManager::Instance();
+    if ((ASession == ManagedSession) &&
+        // prevent tab title flicker, when switching to local-local tab, as the path changes in individual local panels
+        !FSessionChanging)
+    {
+      Path1 = LocalDirView->PathName;
+      Path2 = OtherLocalDirView->PathName;
+    }
+    else
+    {
+      Path1 = ASession->StateData->LocalDirectory;
+      Path2 = ASession->StateData->OtherLocalDirectory;
+    }
+    // See also TSessionData::GetDefaultSessionName()
+    Path1 = Manager->GetPathForSessionTabName(ExtractShortName(Path1, false));
+    Path2 = Manager->GetPathForSessionTabName(ExtractShortName(Path2, false));
+    Result = Path1 + TitleSeparator + Path2;
   }
-  // See also TSessionData::GetDefaultSessionName()
-  Path1 = Manager->GetPathForSessionTabName(ExtractShortName(Path1, false));
-  Path2 = Manager->GetPathForSessionTabName(ExtractShortName(Path2, false));
-  UnicodeString Result = Path1 + TitleSeparator + Path2;
   return Result;
 }