@@ -13,45 +13,36 @@ import { SearchAndCompareView } from './searchAndCompareView';
13
13
import { StashesView } from './stashesView' ;
14
14
import { TagsView } from './tagsView' ;
15
15
import type { TreeViewByType } from './viewBase' ;
16
+ import type { Views } from './views' ;
16
17
import { WorktreesView } from './worktreesView' ;
17
18
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 {
30
20
private _disposable : Disposable ;
31
21
private _view : TreeViewByType [ GroupableTreeViewTypes ] | undefined ;
32
22
33
23
constructor (
34
24
private readonly container : Container ,
25
+ private views : Views ,
35
26
private readonly included : GroupableTreeViewTypes [ ] ,
36
27
) {
37
28
this . _disposable = Disposable . from (
38
- registerCommand ( 'gitlens.views.grouped.refresh' , ( ) => {
29
+ registerCommand ( 'gitlens.views.scm. grouped.refresh' , ( ) => {
39
30
if ( this . _view == null ) return ;
40
31
41
32
executeCommand ( `gitlens.views.${ this . _view . type } .refresh` as Commands ) ;
42
33
} ) ,
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' ) ) ,
52
43
) ;
53
44
54
- this . _view = this . setView ( getLastView ( this . included [ 0 ] ) ) ;
45
+ this . _view = this . setView ( this . views . lastSelectedScmGroupedView ! ) ;
55
46
}
56
47
57
48
dispose ( ) {
@@ -63,11 +54,11 @@ export class GroupedView implements Disposable {
63
54
if ( ! this . included . includes ( type ) ) {
64
55
type = this . included [ 0 ] as T ;
65
56
}
66
- setLastView ( type ) ;
57
+ this . views . lastSelectedScmGroupedView = type ;
67
58
68
59
if ( this . _view ?. type === type ) return this . _view as TreeViewByType [ T ] ;
69
60
70
- void setContext ( 'gitlens:views:grouped:view' , type ) ;
61
+ void setContext ( 'gitlens:views:scm: grouped:view' , type ) ;
71
62
this . _view ?. dispose ( ) ;
72
63
73
64
this . _view = this . getView ( type ) ;
0 commit comments