Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/outline/browser/outlineActions.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { localize } from '../../../../nls.js';
7
import { Codicon } from '../../../../base/common/codicons.js';
8
import { MenuId, registerAction2 } from '../../../../platform/actions/common/actions.js';
9
import { ViewAction } from '../../../browser/parts/views/viewPane.js';
10
import { ContextKeyExpr } from '../../../../platform/contextkey/common/contextkey.js';
11
import { ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js';
12
import { ctxAllCollapsed, ctxFilterOnType, ctxFollowsCursor, ctxSortMode, IOutlinePane, OutlineSortOrder } from './outline.js';
13
14
15
// --- commands
16
17
registerAction2(class CollapseAll extends ViewAction<IOutlinePane> {
18
constructor() {
19
super({
20
viewId: IOutlinePane.Id,
21
id: 'outline.collapse',
22
title: localize('collapse', "Collapse All"),
23
f1: false,
24
icon: Codicon.collapseAll,
25
menu: {
26
id: MenuId.ViewTitle,
27
group: 'navigation',
28
when: ContextKeyExpr.and(ContextKeyExpr.equals('view', IOutlinePane.Id), ctxAllCollapsed.isEqualTo(false))
29
}
30
});
31
}
32
runInView(_accessor: ServicesAccessor, view: IOutlinePane) {
33
view.collapseAll();
34
}
35
});
36
37
registerAction2(class ExpandAll extends ViewAction<IOutlinePane> {
38
constructor() {
39
super({
40
viewId: IOutlinePane.Id,
41
id: 'outline.expand',
42
title: localize('expand', "Expand All"),
43
f1: false,
44
icon: Codicon.expandAll,
45
menu: {
46
id: MenuId.ViewTitle,
47
group: 'navigation',
48
when: ContextKeyExpr.and(ContextKeyExpr.equals('view', IOutlinePane.Id), ctxAllCollapsed.isEqualTo(true))
49
}
50
});
51
}
52
runInView(_accessor: ServicesAccessor, view: IOutlinePane) {
53
view.expandAll();
54
}
55
});
56
57
registerAction2(class FollowCursor extends ViewAction<IOutlinePane> {
58
constructor() {
59
super({
60
viewId: IOutlinePane.Id,
61
id: 'outline.followCursor',
62
title: localize('followCur', "Follow Cursor"),
63
f1: false,
64
toggled: ctxFollowsCursor,
65
menu: {
66
id: MenuId.ViewTitle,
67
group: 'config',
68
order: 1,
69
when: ContextKeyExpr.equals('view', IOutlinePane.Id)
70
}
71
});
72
}
73
runInView(_accessor: ServicesAccessor, view: IOutlinePane) {
74
view.outlineViewState.followCursor = !view.outlineViewState.followCursor;
75
}
76
});
77
78
registerAction2(class FilterOnType extends ViewAction<IOutlinePane> {
79
constructor() {
80
super({
81
viewId: IOutlinePane.Id,
82
id: 'outline.filterOnType',
83
title: localize('filterOnType', "Filter on Type"),
84
f1: false,
85
toggled: ctxFilterOnType,
86
menu: {
87
id: MenuId.ViewTitle,
88
group: 'config',
89
order: 2,
90
when: ContextKeyExpr.equals('view', IOutlinePane.Id)
91
}
92
});
93
}
94
runInView(_accessor: ServicesAccessor, view: IOutlinePane) {
95
view.outlineViewState.filterOnType = !view.outlineViewState.filterOnType;
96
}
97
});
98
99
100
registerAction2(class SortByPosition extends ViewAction<IOutlinePane> {
101
constructor() {
102
super({
103
viewId: IOutlinePane.Id,
104
id: 'outline.sortByPosition',
105
title: localize('sortByPosition', "Sort By: Position"),
106
f1: false,
107
toggled: ctxSortMode.isEqualTo(OutlineSortOrder.ByPosition),
108
menu: {
109
id: MenuId.ViewTitle,
110
group: 'sort',
111
order: 1,
112
when: ContextKeyExpr.equals('view', IOutlinePane.Id)
113
}
114
});
115
}
116
runInView(_accessor: ServicesAccessor, view: IOutlinePane) {
117
view.outlineViewState.sortBy = OutlineSortOrder.ByPosition;
118
}
119
});
120
121
registerAction2(class SortByName extends ViewAction<IOutlinePane> {
122
constructor() {
123
super({
124
viewId: IOutlinePane.Id,
125
id: 'outline.sortByName',
126
title: localize('sortByName', "Sort By: Name"),
127
f1: false,
128
toggled: ctxSortMode.isEqualTo(OutlineSortOrder.ByName),
129
menu: {
130
id: MenuId.ViewTitle,
131
group: 'sort',
132
order: 2,
133
when: ContextKeyExpr.equals('view', IOutlinePane.Id)
134
}
135
});
136
}
137
runInView(_accessor: ServicesAccessor, view: IOutlinePane) {
138
view.outlineViewState.sortBy = OutlineSortOrder.ByName;
139
}
140
});
141
142
registerAction2(class SortByKind extends ViewAction<IOutlinePane> {
143
constructor() {
144
super({
145
viewId: IOutlinePane.Id,
146
id: 'outline.sortByKind',
147
title: localize('sortByKind', "Sort By: Category"),
148
f1: false,
149
toggled: ctxSortMode.isEqualTo(OutlineSortOrder.ByKind),
150
menu: {
151
id: MenuId.ViewTitle,
152
group: 'sort',
153
order: 3,
154
when: ContextKeyExpr.equals('view', IOutlinePane.Id)
155
}
156
});
157
}
158
runInView(_accessor: ServicesAccessor, view: IOutlinePane) {
159
view.outlineViewState.sortBy = OutlineSortOrder.ByKind;
160
}
161
});
162
163