Skip to content

Commit f60d241

Browse files
committed
Renames "grouped" view to "scm.grouped" for future
Adds per-workspace memory to the last selected grouped view
1 parent c2f7e0f commit f60d241

File tree

9 files changed

+502
-483
lines changed

9 files changed

+502
-483
lines changed

docs/telemetry-events.md

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

package.json

Lines changed: 314 additions & 311 deletions
Large diffs are not rendered by default.

src/config.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,9 +621,11 @@ export interface ViewsCommonConfig {
621621
readonly tooltip: string;
622622
};
623623
};
624-
readonly grouped: {
625-
readonly enabled: boolean;
626-
readonly views: GroupableTreeViewTypes[];
624+
readonly scm: {
625+
grouped: {
626+
readonly enabled: boolean;
627+
readonly views: GroupableTreeViewTypes[];
628+
};
627629
};
628630
readonly openChangesInMultiDiffEditor: boolean;
629631
readonly pageItemLimit: number;

src/constants.context.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ export type ContextKeys = {
4444
'gitlens:views:patchDetails:mode': 'create' | 'view';
4545
'gitlens:views:pullRequest:visible': boolean;
4646
'gitlens:views:repositories:autoRefresh': boolean;
47-
'gitlens:views:grouped:default': GroupableTreeViewTypes;
48-
'gitlens:views:grouped:view': GroupableTreeViewTypes;
49-
'gitlens:views:grouped:views': string;
47+
'gitlens:views:scm:grouped:default': GroupableTreeViewTypes;
48+
'gitlens:views:scm:grouped:view': GroupableTreeViewTypes;
49+
'gitlens:views:scm:grouped:views': string;
5050
'gitlens:vsls': boolean | 'host' | 'guest';
5151
'gitlens:window:annotated': AnnotationStatus;
5252
} & Record<`gitlens:action:${string}`, number> &

src/constants.storage.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { GraphBranchesVisibility, ViewShowBranchComparison } from './config
22
import type { AIProviders } from './constants.ai';
33
import type { IntegrationId } from './constants.integrations';
44
import type { TrackedUsage, TrackedUsageKeys } from './constants.telemetry';
5+
import type { GroupableTreeViewTypes } from './constants.views';
56
import type { Environment } from './container';
67
import type { Subscription } from './plus/gk/account/subscription';
78
import type { Integration } from './plus/integrations/integration';
@@ -102,10 +103,11 @@ export type WorkspaceStorage = {
102103
'remote:default': string;
103104
'starred:branches': StoredStarred;
104105
'starred:repositories': StoredStarred;
105-
'views:repositories:autoRefresh': boolean;
106-
'views:searchAndCompare:pinned': StoredSearchAndCompareItems;
107106
'views:commitDetails:autolinksExpanded': boolean;
108107
'views:commitDetails:pullRequestExpanded': boolean;
108+
'views:repositories:autoRefresh': boolean;
109+
'views:searchAndCompare:pinned': StoredSearchAndCompareItems;
110+
'views:scm:grouped:selected': GroupableTreeViewTypes;
109111
} & { [key in `confirm:ai:tos:${AIProviders}`]: boolean } & {
110112
[key in `connected:${Integration['key']}`]: boolean;
111113
};

src/constants.views.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export type TreeViewTypes =
77
| 'contributors'
88
| 'drafts'
99
| 'fileHistory'
10-
| 'grouped'
10+
| 'scm.grouped'
1111
| 'launchpad'
1212
| 'lineHistory'
1313
| 'pullRequest'

src/views/groupedView.ts renamed to src/views/scmGroupedView.ts

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,36 @@ import { SearchAndCompareView } from './searchAndCompareView';
1313
import { StashesView } from './stashesView';
1414
import { TagsView } from './tagsView';
1515
import type { TreeViewByType } from './viewBase';
16+
import type { Views } from './views';
1617
import { WorktreesView } from './worktreesView';
1718

18-
let lastView: GroupableTreeViewTypes | undefined;
19-
export function getLastView(): GroupableTreeViewTypes | undefined;
20-
export function getLastView(defaultType: GroupableTreeViewTypes): GroupableTreeViewTypes;
21-
export function getLastView(defaultType?: GroupableTreeViewTypes) {
22-
return lastView ?? defaultType;
23-
}
24-
25-
export function setLastView(type: GroupableTreeViewTypes | undefined) {
26-
lastView = type;
27-
}
28-
29-
export class GroupedView implements Disposable {
19+
export class ScmGroupedView implements Disposable {
3020
private _disposable: Disposable;
3121
private _view: TreeViewByType[GroupableTreeViewTypes] | undefined;
3222

3323
constructor(
3424
private readonly container: Container,
25+
private views: Views,
3526
private readonly included: GroupableTreeViewTypes[],
3627
) {
3728
this._disposable = Disposable.from(
38-
registerCommand('gitlens.views.grouped.refresh', () => {
29+
registerCommand('gitlens.views.scm.grouped.refresh', () => {
3930
if (this._view == null) return;
4031

4132
executeCommand(`gitlens.views.${this._view.type}.refresh` as Commands);
4233
}),
43-
registerCommand('gitlens.views.grouped.branches', () => this.setView('branches')),
44-
registerCommand('gitlens.views.grouped.commits', () => this.setView('commits')),
45-
registerCommand('gitlens.views.grouped.contributors', () => this.setView('contributors')),
46-
registerCommand('gitlens.views.grouped.remotes', () => this.setView('remotes')),
47-
registerCommand('gitlens.views.grouped.repositories', () => this.setView('repositories')),
48-
registerCommand('gitlens.views.grouped.searchAndCompare', () => this.setView('searchAndCompare')),
49-
registerCommand('gitlens.views.grouped.stashes', () => this.setView('stashes')),
50-
registerCommand('gitlens.views.grouped.tags', () => this.setView('tags')),
51-
registerCommand('gitlens.views.grouped.worktrees', () => this.setView('worktrees')),
34+
registerCommand('gitlens.views.scm.grouped.branches', () => this.setView('branches')),
35+
registerCommand('gitlens.views.scm.grouped.commits', () => this.setView('commits')),
36+
registerCommand('gitlens.views.scm.grouped.contributors', () => this.setView('contributors')),
37+
registerCommand('gitlens.views.scm.grouped.remotes', () => this.setView('remotes')),
38+
registerCommand('gitlens.views.scm.grouped.repositories', () => this.setView('repositories')),
39+
registerCommand('gitlens.views.scm.grouped.searchAndCompare', () => this.setView('searchAndCompare')),
40+
registerCommand('gitlens.views.scm.grouped.stashes', () => this.setView('stashes')),
41+
registerCommand('gitlens.views.scm.grouped.tags', () => this.setView('tags')),
42+
registerCommand('gitlens.views.scm.grouped.worktrees', () => this.setView('worktrees')),
5243
);
5344

54-
this._view = this.setView(getLastView(this.included[0]));
45+
this._view = this.setView(this.views.lastSelectedScmGroupedView!);
5546
}
5647

5748
dispose() {
@@ -63,11 +54,11 @@ export class GroupedView implements Disposable {
6354
if (!this.included.includes(type)) {
6455
type = this.included[0] as T;
6556
}
66-
setLastView(type);
57+
this.views.lastSelectedScmGroupedView = type;
6758

6859
if (this._view?.type === type) return this._view as TreeViewByType[T];
6960

70-
void setContext('gitlens:views:grouped:view', type);
61+
void setContext('gitlens:views:scm:grouped:view', type);
7162
this._view?.dispose();
7263

7364
this._view = this.getView(type);

src/views/viewBase.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ export abstract class ViewBase<
369369
}
370370

371371
protected initialize(options: { canSelectMany?: boolean; showCollapseAll?: boolean } = {}) {
372-
this.tree = window.createTreeView<ViewNode>(this.grouped ? 'gitlens.views.grouped' : this.id, {
372+
this.tree = window.createTreeView<ViewNode>(this.grouped ? 'gitlens.views.scm.grouped' : this.id, {
373373
...options,
374374
treeDataProvider: this,
375375
});
@@ -730,7 +730,7 @@ export abstract class ViewBase<
730730
const scope = getLogScope();
731731

732732
try {
733-
const command = `${this.grouped ? 'gitlens.views.grouped' : this.id}.focus` as const;
733+
const command = `${this.grouped ? 'gitlens.views.scm.grouped' : this.id}.focus` as const;
734734
// If we haven't been initialized, the focus command will show the view, but won't focus it, so wait until it's initialized and then focus again
735735
if (!this.initialized) {
736736
void executeCoreCommand(command, options);

0 commit comments

Comments
 (0)