Skip to content

Commit baa34ae

Browse files
authored
fix: branch name in toolbar not updated immediately after renaming current branch (#2470)
1 parent c7bab7a commit baa34ae

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

‎src/ViewModels/Repository.cs‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,8 +847,29 @@ public void RefreshAfterRenameBranch(Models.Branch b, string newName)
847847
var newFullName = $"refs/heads/{newName}";
848848
_uiStates.RenameBranchFilter(b.FullName, newFullName);
849849

850-
b.Name = newName;
851-
b.FullName = newFullName;
850+
var renamed = new Models.Branch
851+
{
852+
Name = newName,
853+
FullName = newFullName,
854+
CommitterDate = b.CommitterDate,
855+
Head = b.Head,
856+
IsLocal = b.IsLocal,
857+
IsCurrent = b.IsCurrent,
858+
IsDetachedHead = b.IsDetachedHead,
859+
Upstream = b.Upstream,
860+
Ahead = b.Ahead,
861+
Behind = b.Behind,
862+
Remote = b.Remote,
863+
IsUpstreamGone = b.IsUpstreamGone,
864+
WorktreePath = b.WorktreePath,
865+
};
866+
867+
var idx = _branches.IndexOf(b);
868+
if (idx >= 0)
869+
_branches[idx] = renamed;
870+
871+
if (b.IsCurrent)
872+
CurrentBranch = renamed;
852873

853874
List<Models.Branch> locals = [];
854875
foreach (var branch in _branches)

0 commit comments

Comments
 (0)