Skip to content

Commit 751522a

Browse files
committed
Closes #3520 adds setting to show current branch on top
1 parent 5c97108 commit 751522a

File tree

7 files changed

+46
-7
lines changed

7 files changed

+46
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
66

77
## [Unreleased]
88

9+
### Added
10+
11+
- Adds a `gitlens.views.showCurrentBranchOnTop` setting to specify whether the current branch is shown at the top of the views — closes [#3520](https://github.com/gitkraken/vscode-gitlens/issues/3520)
12+
913
### Fixed
1014

1115
- Fixes [#3514](https://github.com/gitkraken/vscode-gitlens/issues/3514) - Attempting to delete the main worktree's branch causes a invalid prompt to delete the main worktree

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,6 +1393,13 @@
13931393
"scope": "window",
13941394
"order": 1
13951395
},
1396+
"gitlens.views.showCurrentBranchOnTop": {
1397+
"type": "boolean",
1398+
"default": true,
1399+
"markdownDescription": "Specifies whether to always show the current branch at the top of the views",
1400+
"scope": "window",
1401+
"order": 2
1402+
},
13961403
"gitlens.views.defaultItemLimit": {
13971404
"type": "number",
13981405
"default": 10,

src/config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,13 +615,16 @@ export interface ViewsCommonConfig {
615615
};
616616
readonly openChangesInMultiDiffEditor: boolean;
617617
readonly pageItemLimit: number;
618+
readonly showCurrentBranchOnTop: boolean;
618619
readonly showRelativeDateMarkers: boolean;
619620
}
620621

621622
export const viewsCommonConfigKeys: (keyof ViewsCommonConfig)[] = [
623+
'collapseWorktreesWhenPossible',
622624
'defaultItemLimit',
623625
'formats',
624626
'pageItemLimit',
627+
'showCurrentBranchOnTop',
625628
'showRelativeDateMarkers',
626629
];
627630

src/views/branchesView.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ export class BranchesView extends ViewBase<'branches', BranchesViewNode, Branche
199199
!configuration.changed(e, 'defaultGravatarsStyle') &&
200200
!configuration.changed(e, 'defaultTimeFormat') &&
201201
!configuration.changed(e, 'sortBranchesBy') &&
202-
!configuration.changed(e, 'sortRepositoriesBy') &&
203-
!configuration.changed(e, 'views.collapseWorktreesWhenPossible')
202+
!configuration.changed(e, 'sortRepositoriesBy')
204203
) {
205204
return false;
206205
}

src/views/nodes/branchesNode.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ export class BranchesNode extends CacheableChildrenViewNode<'branches', ViewsWit
3838
const branches = await this.repo.getBranches({
3939
// only show local branches
4040
filter: b => !b.remote,
41-
sort: {
42-
current: true,
43-
openedWorktreesByBranch: getOpenedWorktreesByBranch(this.context.worktreesByBranch),
44-
},
41+
sort: this.view.config.showCurrentBranchOnTop
42+
? {
43+
current: true,
44+
openedWorktreesByBranch: getOpenedWorktreesByBranch(this.context.worktreesByBranch),
45+
}
46+
: { current: false },
4547
});
4648
if (branches.values.length === 0) return [new MessageNode(this.view, this, 'No branches could be found.')];
4749

src/views/repositoriesView.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ export class RepositoriesView extends ViewBase<'repositories', RepositoriesNode,
258258

259259
return true;
260260
}
261+
261262
protected override onConfigurationChanged(e: ConfigurationChangeEvent) {
262263
if (configuration.changed(e, `views.${this.configKey}.autoRefresh` as const)) {
263264
void this.setAutoRefresh(configuration.get('views.repositories.autoRefresh'));

src/views/workspacesView.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { CancellationToken, Disposable } from 'vscode';
1+
import type { CancellationToken, ConfigurationChangeEvent, Disposable } from 'vscode';
22
import { ProgressLocation, TreeItem, TreeItemCollapsibleState, window } from 'vscode';
33
import type { WorkspacesViewConfig } from '../config';
44
import { previewBadge, urls } from '../constants';
@@ -8,6 +8,7 @@ import { unknownGitUri } from '../git/gitUri';
88
import type { Repository } from '../git/models/repository';
99
import { ensurePlusFeaturesEnabled } from '../plus/gk/utils';
1010
import { executeCommand } from '../system/command';
11+
import { configuration } from '../system/configuration';
1112
import { gate } from '../system/decorators/gate';
1213
import { debug } from '../system/decorators/log';
1314
import { openUrl, openWorkspace } from '../system/utils';
@@ -313,4 +314,26 @@ export class WorkspacesView extends ViewBase<'workspaces', WorkspacesViewNode, W
313314
),
314315
];
315316
}
317+
318+
protected override filterConfigurationChanged(e: ConfigurationChangeEvent) {
319+
const changed = super.filterConfigurationChanged(e);
320+
if (
321+
!changed &&
322+
!configuration.changed(e, 'defaultDateFormat') &&
323+
!configuration.changed(e, 'defaultDateLocale') &&
324+
!configuration.changed(e, 'defaultDateShortFormat') &&
325+
!configuration.changed(e, 'defaultDateSource') &&
326+
!configuration.changed(e, 'defaultDateStyle') &&
327+
!configuration.changed(e, 'defaultGravatarsStyle') &&
328+
!configuration.changed(e, 'defaultTimeFormat') &&
329+
!configuration.changed(e, 'sortBranchesBy') &&
330+
!configuration.changed(e, 'sortContributorsBy') &&
331+
!configuration.changed(e, 'sortTagsBy') &&
332+
!configuration.changed(e, 'sortRepositoriesBy')
333+
) {
334+
return false;
335+
}
336+
337+
return true;
338+
}
316339
}

0 commit comments

Comments
 (0)