File tree Expand file tree Collapse file tree 2 files changed +50
-9
lines changed
Expand file tree Collapse file tree 2 files changed +50
-9
lines changed Original file line number Diff line number Diff line change @@ -80,18 +80,15 @@ public override async Task<bool> Sure()
8080 await new Commands . Stash ( _repo . FullPath )
8181 . Use ( log )
8282 . PopAsync ( "stash@{0}" ) ;
83+
84+ _repo . FastRefreshBranchesAfterCheckout ( Branch ) ;
85+ }
86+ else
87+ {
88+ _repo . MarkWorkingCopyDirtyManually ( ) ;
8389 }
8490
8591 log . Complete ( ) ;
86-
87- var b = _repo . Branches . Find ( x => x . IsLocal && x . Name == Branch ) ;
88- if ( b != null && _repo . HistoryFilterMode == Models . FilterMode . Included )
89- _repo . SetBranchFilterMode ( b , Models . FilterMode . Included , false , false ) ;
90-
91- _repo . MarkBranchesDirtyManually ( ) ;
92-
93- ProgressDescription = "Waiting for branch updated..." ;
94- await Task . Delay ( 400 ) ;
9592 return succ ;
9693 }
9794
Original file line number Diff line number Diff line change @@ -788,6 +788,50 @@ public IDisposable LockWatcher()
788788 return _watcher ? . Lock ( ) ;
789789 }
790790
791+ public void FastRefreshBranchesAfterCheckout ( string checkouted )
792+ {
793+ _watcher ? . MarkBranchUpdated ( ) ;
794+ _watcher ? . MarkWorkingCopyUpdated ( ) ;
795+
796+ var oldWorktree = _currentBranch . WorktreePath ;
797+ _currentBranch . WorktreePath = null ;
798+
799+ List < Models . Branch > locals = [ ] ;
800+ Models . Branch detached = null ;
801+ foreach ( var b in _branches )
802+ {
803+ if ( b . IsLocal )
804+ {
805+ if ( b . IsDetachedHead )
806+ {
807+ detached = b ;
808+ continue ;
809+ }
810+
811+ b . IsCurrent = b . Name . Equals ( checkouted , StringComparison . Ordinal ) ;
812+ if ( b . IsCurrent )
813+ {
814+ CurrentBranch = b ;
815+ b . WorktreePath = oldWorktree ;
816+ if ( _historyFilterMode == Models . FilterMode . Included )
817+ SetBranchFilterMode ( b , Models . FilterMode . Included , false , false ) ;
818+ }
819+
820+ locals . Add ( b ) ;
821+ }
822+ }
823+
824+ if ( detached != null )
825+ _branches . Remove ( detached ) ;
826+
827+ var builder = BuildBranchTree ( locals , [ ] ) ;
828+ LocalBranchTrees = builder . Locals ;
829+
830+ RefreshCommits ( ) ;
831+ RefreshWorkingCopyChanges ( ) ;
832+ RefreshWorktrees ( ) ;
833+ }
834+
791835 public void MarkBranchesDirtyManually ( )
792836 {
793837 _watcher ? . MarkBranchUpdated ( ) ;
You can’t perform that action at this time.
0 commit comments