Skip to content

Commit 684d59f

Browse files
authored
Merge pull request #81 from devxoul/move-worktree-before-branch
Move worktree selector to the left of branch selector
2 parents 6970977 + 5f593a0 commit 684d59f

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

app/src/lib/stores/app-store.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2679,12 +2679,24 @@ export class AppStore extends TypedBaseStore<IAppState> {
26792679
this.commitSummaryWidth = constrain(this.commitSummaryWidth, 100, filesMax)
26802680
this.stashedFilesWidth = constrain(this.stashedFilesWidth, 100, filesMax)
26812681

2682-
// Allocate branch first (highest priority), then worktree, then
2682+
// Allocate worktree first (highest priority), then branch, then
26832683
// push-pull. Each subsequent allocation uses the clamped value of the
26842684
// previous to prevent the total from exceeding the available space.
2685+
const worktreeDropdownMax =
2686+
available - defaultBranchDropdownWidth - defaultPushPullButtonWidth
2687+
const minimumWorktreeDropdownWidth =
2688+
defaultWorktreeDropdownWidth > available / numButtons
2689+
? available / numButtons - 10
2690+
: defaultWorktreeDropdownWidth
2691+
this.worktreeDropdownWidth = constrain(
2692+
this.worktreeDropdownWidth,
2693+
minimumWorktreeDropdownWidth,
2694+
worktreeDropdownMax
2695+
)
2696+
26852697
const branchDropdownMax =
26862698
available -
2687-
(this.showWorktrees ? defaultWorktreeDropdownWidth : 0) -
2699+
(this.showWorktrees ? clamp(this.worktreeDropdownWidth) : 0) -
26882700
defaultPushPullButtonWidth
26892701
const minimumBranchDropdownWidth =
26902702
defaultBranchDropdownWidth > available / numButtons
@@ -2696,22 +2708,10 @@ export class AppStore extends TypedBaseStore<IAppState> {
26962708
branchDropdownMax
26972709
)
26982710

2699-
const worktreeDropdownMax =
2700-
available - clamp(this.branchDropdownWidth) - defaultPushPullButtonWidth
2701-
const minimumWorktreeDropdownWidth =
2702-
defaultWorktreeDropdownWidth > available / numButtons
2703-
? available / numButtons - 10
2704-
: defaultWorktreeDropdownWidth
2705-
this.worktreeDropdownWidth = constrain(
2706-
this.worktreeDropdownWidth,
2707-
minimumWorktreeDropdownWidth,
2708-
worktreeDropdownMax
2709-
)
2710-
27112711
const pushPullButtonMaxWidth =
27122712
available -
2713-
clamp(this.branchDropdownWidth) -
2714-
(this.showWorktrees ? clamp(this.worktreeDropdownWidth) : 0)
2713+
(this.showWorktrees ? clamp(this.worktreeDropdownWidth) : 0) -
2714+
clamp(this.branchDropdownWidth)
27152715
const minimumPushPullToolBarWidth =
27162716
defaultPushPullButtonWidth > available / numButtons
27172717
? available / numButtons - 10

app/src/ui/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3561,8 +3561,8 @@ export class App extends React.Component<IAppProps, IAppState> {
35613561
<div className="sidebar-section" style={{ width }}>
35623562
{this.renderRepositoryToolbarButton()}
35633563
</div>
3564-
{this.renderBranchToolbarButton()}
35653564
{this.renderWorktreeToolbarButton()}
3565+
{this.renderBranchToolbarButton()}
35663566
{this.renderPushPullToolbarButton()}
35673567
</Toolbar>
35683568
)

0 commit comments

Comments
 (0)