File tree Expand file tree Collapse file tree 2 files changed +25
-6
lines changed Expand file tree Collapse file tree 2 files changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,11 @@ import {
12
12
providesList ,
13
13
ReduxTag
14
14
} from '$lib/state/tags' ;
15
- import { replaceBranchInExclusiveAction , type UiState } from '$lib/state/uiState.svelte' ;
15
+ import {
16
+ replaceBranchInExclusiveAction ,
17
+ replaceBranchInStackSelection ,
18
+ type UiState
19
+ } from '$lib/state/uiState.svelte' ;
16
20
import { isDefined } from '@gitbutler/ui/utils/typeguards' ;
17
21
import {
18
22
createEntityAdapter ,
@@ -615,12 +619,16 @@ export class StackService {
615
619
const stackState = this . uiState . stack ( args . stackId ) ;
616
620
const projectState = this . uiState . project ( args . projectId ) ;
617
621
const exclusiveAction = projectState . exclusiveAction . current ;
618
- const previousSelection = stackState . selection . current ?? { } ;
622
+ const previousSelection = stackState . selection . current ;
619
623
620
- stackState . selection . set ( {
621
- ...previousSelection ,
622
- branchName : args . newName
623
- } ) ;
624
+ if ( previousSelection ) {
625
+ const updatedSelection = replaceBranchInStackSelection (
626
+ previousSelection ,
627
+ args . branchName ,
628
+ args . newName
629
+ ) ;
630
+ stackState . selection . set ( updatedSelection ) ;
631
+ }
624
632
625
633
if ( exclusiveAction ) {
626
634
const updatedExclusiveAction = replaceBranchInExclusiveAction (
Original file line number Diff line number Diff line change @@ -267,3 +267,14 @@ export function replaceBranchInExclusiveAction(
267
267
return action ;
268
268
}
269
269
}
270
+
271
+ export function replaceBranchInStackSelection (
272
+ selection : StackSelection ,
273
+ oldBranchName : string ,
274
+ branchName : string
275
+ ) : StackSelection {
276
+ if ( selection . branchName === oldBranchName ) {
277
+ return { ...selection , branchName } ;
278
+ }
279
+ return selection ;
280
+ }
You can’t perform that action at this time.
0 commit comments