@codingame/monaco-vscode-views-service-override 1.85.2 → 1.85.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,307 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import './outlinePane.css.js';
3
- import * as dom from 'monaco-editor/esm/vs/base/browser/dom.js';
4
- import { ProgressBar } from 'monaco-editor/esm/vs/base/browser/ui/progressbar/progressbar.js';
5
- import { TimeoutTimer } from 'monaco-editor/esm/vs/base/common/async.js';
6
- import { DisposableStore, MutableDisposable, toDisposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
7
- import { LRUCache } from 'monaco-editor/esm/vs/base/common/map.js';
8
- import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
9
- import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
10
- import { IContextKeyService } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
11
- import { IContextMenuService } from 'monaco-editor/esm/vs/platform/contextview/browser/contextView.js';
12
- import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
13
- import { IKeybindingService } from 'monaco-editor/esm/vs/platform/keybinding/common/keybinding.js';
14
- import { WorkbenchDataTree } from 'monaco-editor/esm/vs/platform/list/browser/listService.js';
15
- import { IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
16
- import { IThemeService } from 'monaco-editor/esm/vs/platform/theme/common/themeService.js';
17
- import { ViewPane } from 'vscode/vscode/vs/workbench/browser/parts/views/viewPane';
18
- import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
19
- import { basename } from 'monaco-editor/esm/vs/base/common/resources.js';
20
- import { IViewDescriptorService } from 'vscode/vscode/vs/workbench/common/views';
21
- import { IOpenerService } from 'monaco-editor/esm/vs/platform/opener/common/opener.js';
22
- import { ITelemetryService } from 'monaco-editor/esm/vs/platform/telemetry/common/telemetry.js';
23
- import { OutlineViewState } from './outlineViewState.js';
24
- import { IOutlineService } from 'vscode/vscode/vs/workbench/services/outline/browser/outline';
25
- import { EditorResourceAccessor } from 'vscode/vscode/vs/workbench/common/editor';
26
- import { CancellationTokenSource } from 'monaco-editor/esm/vs/base/common/cancellation.js';
27
- import { Event } from 'monaco-editor/esm/vs/base/common/event.js';
28
- import { TreeFindMode, AbstractTreeViewState } from 'monaco-editor/esm/vs/base/browser/ui/tree/abstractTree.js';
29
- import { ctxFollowsCursor, ctxFilterOnType, ctxSortMode, ctxAllCollapsed } from './outline.js';
30
- import { defaultProgressBarStyles } from 'monaco-editor/esm/vs/platform/theme/browser/defaultStyles.js';
31
-
32
- class OutlineTreeSorter {
33
- constructor(_comparator, order) {
34
- this._comparator = _comparator;
35
- this.order = order;
36
- }
37
- compare(a, b) {
38
- if (this.order === 2 ) {
39
- return this._comparator.compareByType(a, b);
40
- }
41
- else if (this.order === 1 ) {
42
- return this._comparator.compareByName(a, b);
43
- }
44
- else {
45
- return this._comparator.compareByPosition(a, b);
46
- }
47
- }
48
- }
49
- let OutlinePane = class OutlinePane extends ViewPane {
50
- static { this.Id = 'outline'; }
51
- constructor(options, _outlineService, _instantiationService, viewDescriptorService, _storageService, _editorService, configurationService, keybindingService, contextKeyService, contextMenuService, openerService, themeService, telemetryService) {
52
- super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, _instantiationService, openerService, themeService, telemetryService);
53
- this._outlineService = _outlineService;
54
- this._instantiationService = _instantiationService;
55
- this._storageService = _storageService;
56
- this._editorService = _editorService;
57
- this._disposables = ( new DisposableStore());
58
- this._editorControlDisposables = ( new DisposableStore());
59
- this._editorPaneDisposables = ( new DisposableStore());
60
- this._outlineViewState = ( new OutlineViewState());
61
- this._editorListener = ( new MutableDisposable());
62
- this._treeStates = ( new LRUCache(10));
63
- this._outlineViewState.restore(this._storageService);
64
- this._disposables.add(this._outlineViewState);
65
- contextKeyService.bufferChangeEvents(() => {
66
- this._ctxFollowsCursor = ctxFollowsCursor.bindTo(contextKeyService);
67
- this._ctxFilterOnType = ctxFilterOnType.bindTo(contextKeyService);
68
- this._ctxSortMode = ctxSortMode.bindTo(contextKeyService);
69
- this._ctxAllCollapsed = ctxAllCollapsed.bindTo(contextKeyService);
70
- });
71
- const updateContext = () => {
72
- this._ctxFollowsCursor.set(this._outlineViewState.followCursor);
73
- this._ctxFilterOnType.set(this._outlineViewState.filterOnType);
74
- this._ctxSortMode.set(this._outlineViewState.sortBy);
75
- };
76
- updateContext();
77
- this._disposables.add(this._outlineViewState.onDidChange(updateContext));
78
- }
79
- dispose() {
80
- this._disposables.dispose();
81
- this._editorPaneDisposables.dispose();
82
- this._editorControlDisposables.dispose();
83
- this._editorListener.dispose();
84
- super.dispose();
85
- }
86
- focus() {
87
- super.focus();
88
- this._tree?.domFocus();
89
- }
90
- renderBody(container) {
91
- super.renderBody(container);
92
- this._domNode = container;
93
- container.classList.add('outline-pane');
94
- const progressContainer = dom.$('.outline-progress');
95
- this._message = dom.$('.outline-message');
96
- this._progressBar = ( new ProgressBar(progressContainer, defaultProgressBarStyles));
97
- this._treeContainer = dom.$('.outline-tree');
98
- dom.append(container, progressContainer, this._message, this._treeContainer);
99
- this._disposables.add(this.onDidChangeBodyVisibility(visible => {
100
- if (!visible) {
101
- this._editorListener.clear();
102
- this._editorPaneDisposables.clear();
103
- this._editorControlDisposables.clear();
104
- }
105
- else if (!this._editorListener.value) {
106
- const event = Event.any(this._editorService.onDidActiveEditorChange, this._outlineService.onDidChange);
107
- this._editorListener.value = event(() => this._handleEditorChanged(this._editorService.activeEditorPane));
108
- this._handleEditorChanged(this._editorService.activeEditorPane);
109
- }
110
- }));
111
- }
112
- layoutBody(height, width) {
113
- super.layoutBody(height, width);
114
- this._tree?.layout(height, width);
115
- this._treeDimensions = new dom.Dimension(width, height);
116
- }
117
- collapseAll() {
118
- this._tree?.collapseAll();
119
- }
120
- expandAll() {
121
- this._tree?.expandAll();
122
- }
123
- get outlineViewState() {
124
- return this._outlineViewState;
125
- }
126
- _showMessage(message) {
127
- this._domNode.classList.add('message');
128
- this._progressBar.stop().hide();
129
- this._message.innerText = message;
130
- }
131
- _captureViewState(uri) {
132
- if (this._tree) {
133
- const oldOutline = this._tree.getInput();
134
- if (!uri) {
135
- uri = oldOutline?.uri;
136
- }
137
- if (oldOutline && uri) {
138
- this._treeStates.set(`${oldOutline.outlineKind}/${uri}`, this._tree.getViewState());
139
- return true;
140
- }
141
- }
142
- return false;
143
- }
144
- _handleEditorChanged(pane) {
145
- this._editorPaneDisposables.clear();
146
- if (pane) {
147
- this._editorPaneDisposables.add(pane.onDidChangeControl(() => {
148
- this._handleEditorControlChanged(pane);
149
- }));
150
- }
151
- this._handleEditorControlChanged(pane);
152
- }
153
- async _handleEditorControlChanged(pane) {
154
- const resource = EditorResourceAccessor.getOriginalUri(pane?.input);
155
- const didCapture = this._captureViewState();
156
- this._editorControlDisposables.clear();
157
- if (!pane || !this._outlineService.canCreateOutline(pane) || !resource) {
158
- return this._showMessage(( localizeWithPath(
159
- 'vs/workbench/contrib/outline/browser/outlinePane',
160
- 'no-editor',
161
- "The active editor cannot provide outline information."
162
- )));
163
- }
164
- let loadingMessage;
165
- if (!didCapture) {
166
- loadingMessage = ( new TimeoutTimer(() => {
167
- this._showMessage(( localizeWithPath(
168
- 'vs/workbench/contrib/outline/browser/outlinePane',
169
- 'loading',
170
- "Loading document symbols for '{0}'...",
171
- basename(resource)
172
- )));
173
- }, 100));
174
- }
175
- this._progressBar.infinite().show(500);
176
- const cts = ( new CancellationTokenSource());
177
- this._editorControlDisposables.add(toDisposable(() => cts.dispose(true)));
178
- const newOutline = await this._outlineService.createOutline(pane, 1 , cts.token);
179
- loadingMessage?.dispose();
180
- if (!newOutline) {
181
- return;
182
- }
183
- if (cts.token.isCancellationRequested) {
184
- newOutline?.dispose();
185
- return;
186
- }
187
- this._editorControlDisposables.add(newOutline);
188
- this._progressBar.stop().hide();
189
- const sorter = ( new OutlineTreeSorter(newOutline.config.comparator, this._outlineViewState.sortBy));
190
- const tree = this._instantiationService.createInstance(WorkbenchDataTree, 'OutlinePane', this._treeContainer, newOutline.config.delegate, newOutline.config.renderers, newOutline.config.treeDataSource, {
191
- ...newOutline.config.options,
192
- sorter,
193
- expandOnDoubleClick: false,
194
- expandOnlyOnTwistieClick: true,
195
- multipleSelectionSupport: false,
196
- hideTwistiesOfChildlessElements: true,
197
- defaultFindMode: this._outlineViewState.filterOnType ? TreeFindMode.Filter : TreeFindMode.Highlight,
198
- overrideStyles: { listBackground: this.getBackgroundColor() }
199
- });
200
- const updateTree = () => {
201
- if (newOutline.isEmpty) {
202
- this._showMessage(( localizeWithPath(
203
- 'vs/workbench/contrib/outline/browser/outlinePane',
204
- 'no-symbols',
205
- "No symbols found in document '{0}'",
206
- basename(resource)
207
- )));
208
- this._captureViewState(resource);
209
- tree.setInput(undefined);
210
- }
211
- else if (!tree.getInput()) {
212
- this._domNode.classList.remove('message');
213
- const state = this._treeStates.get(`${newOutline.outlineKind}/${newOutline.uri}`);
214
- tree.setInput(newOutline, state && AbstractTreeViewState.lift(state));
215
- }
216
- else {
217
- this._domNode.classList.remove('message');
218
- tree.updateChildren();
219
- }
220
- };
221
- updateTree();
222
- this._editorControlDisposables.add(newOutline.onDidChange(updateTree));
223
- tree.findMode = this._outlineViewState.filterOnType ? TreeFindMode.Filter : TreeFindMode.Highlight;
224
- this._editorControlDisposables.add(this.viewDescriptorService.onDidChangeLocation(({ views }) => {
225
- if (( views.some(v => v.id === this.id))) {
226
- tree.updateOptions({ overrideStyles: { listBackground: this.getBackgroundColor() } });
227
- }
228
- }));
229
- this._editorControlDisposables.add(tree.onDidChangeFindMode(mode => this._outlineViewState.filterOnType = mode === TreeFindMode.Filter));
230
- this._editorControlDisposables.add(tree.onDidOpen(e => newOutline.reveal(e.element, e.editorOptions, e.sideBySide)));
231
- const revealActiveElement = () => {
232
- if (!this._outlineViewState.followCursor || !newOutline.activeElement) {
233
- return;
234
- }
235
- let item = newOutline.activeElement;
236
- while (item) {
237
- const top = tree.getRelativeTop(item);
238
- if (top === null) {
239
- tree.reveal(item, 0.5);
240
- }
241
- if (tree.getRelativeTop(item) !== null) {
242
- tree.setFocus([item]);
243
- tree.setSelection([item]);
244
- break;
245
- }
246
- item = tree.getParentElement(item);
247
- }
248
- };
249
- revealActiveElement();
250
- this._editorControlDisposables.add(newOutline.onDidChange(revealActiveElement));
251
- this._editorControlDisposables.add(this._outlineViewState.onDidChange((e) => {
252
- this._outlineViewState.persist(this._storageService);
253
- if (e.filterOnType) {
254
- tree.findMode = this._outlineViewState.filterOnType ? TreeFindMode.Filter : TreeFindMode.Highlight;
255
- }
256
- if (e.followCursor) {
257
- revealActiveElement();
258
- }
259
- if (e.sortBy) {
260
- sorter.order = this._outlineViewState.sortBy;
261
- tree.resort();
262
- }
263
- }));
264
- let viewState;
265
- this._editorControlDisposables.add(tree.onDidChangeFindPattern(pattern => {
266
- if (tree.findMode === TreeFindMode.Highlight) {
267
- return;
268
- }
269
- if (!viewState && pattern) {
270
- viewState = tree.getViewState();
271
- tree.expandAll();
272
- }
273
- else if (!pattern && viewState) {
274
- tree.setInput(tree.getInput(), viewState);
275
- viewState = undefined;
276
- }
277
- }));
278
- const updateAllCollapsedCtx = () => {
279
- this._ctxAllCollapsed.set(tree.getNode(null).children.every(node => !node.collapsible || node.collapsed));
280
- };
281
- this._editorControlDisposables.add(tree.onDidChangeCollapseState(updateAllCollapsedCtx));
282
- this._editorControlDisposables.add(tree.onDidChangeModel(updateAllCollapsedCtx));
283
- updateAllCollapsedCtx();
284
- tree.layout(this._treeDimensions?.height, this._treeDimensions?.width);
285
- this._tree = tree;
286
- this._editorControlDisposables.add(toDisposable(() => {
287
- tree.dispose();
288
- this._tree = undefined;
289
- }));
290
- }
291
- };
292
- OutlinePane = ( __decorate([
293
- ( __param(1, IOutlineService)),
294
- ( __param(2, IInstantiationService)),
295
- ( __param(3, IViewDescriptorService)),
296
- ( __param(4, IStorageService)),
297
- ( __param(5, IEditorService)),
298
- ( __param(6, IConfigurationService)),
299
- ( __param(7, IKeybindingService)),
300
- ( __param(8, IContextKeyService)),
301
- ( __param(9, IContextMenuService)),
302
- ( __param(10, IOpenerService)),
303
- ( __param(11, IThemeService)),
304
- ( __param(12, ITelemetryService))
305
- ], OutlinePane));
306
-
307
- export { OutlinePane };
@@ -1,68 +0,0 @@
1
- import { Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
2
-
3
- class OutlineViewState {
4
- constructor() {
5
- this._followCursor = false;
6
- this._filterOnType = true;
7
- this._sortBy = 0 ;
8
- this._onDidChange = ( new Emitter());
9
- this.onDidChange = this._onDidChange.event;
10
- }
11
- dispose() {
12
- this._onDidChange.dispose();
13
- }
14
- set followCursor(value) {
15
- if (value !== this._followCursor) {
16
- this._followCursor = value;
17
- this._onDidChange.fire({ followCursor: true });
18
- }
19
- }
20
- get followCursor() {
21
- return this._followCursor;
22
- }
23
- get filterOnType() {
24
- return this._filterOnType;
25
- }
26
- set filterOnType(value) {
27
- if (value !== this._filterOnType) {
28
- this._filterOnType = value;
29
- this._onDidChange.fire({ filterOnType: true });
30
- }
31
- }
32
- set sortBy(value) {
33
- if (value !== this._sortBy) {
34
- this._sortBy = value;
35
- this._onDidChange.fire({ sortBy: true });
36
- }
37
- }
38
- get sortBy() {
39
- return this._sortBy;
40
- }
41
- persist(storageService) {
42
- storageService.store('outline/state', JSON.stringify({
43
- followCursor: this.followCursor,
44
- sortBy: this.sortBy,
45
- filterOnType: this.filterOnType,
46
- }), 1 , 1 );
47
- }
48
- restore(storageService) {
49
- const raw = storageService.get('outline/state', 1 );
50
- if (!raw) {
51
- return;
52
- }
53
- let data;
54
- try {
55
- data = JSON.parse(raw);
56
- }
57
- catch (e) {
58
- return;
59
- }
60
- this.followCursor = data.followCursor;
61
- this.sortBy = data.sortBy ?? 0 ;
62
- if (typeof data.filterOnType === 'boolean') {
63
- this.filterOnType = data.filterOnType;
64
- }
65
- }
66
- }
67
-
68
- export { OutlineViewState };
@@ -1,37 +0,0 @@
1
- import { toDisposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
2
- import { LinkedList } from 'monaco-editor/esm/vs/base/common/linkedList.js';
3
- import { Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
4
-
5
- class OutlineService {
6
- constructor() {
7
- this._factories = ( new LinkedList());
8
- this._onDidChange = ( new Emitter());
9
- this.onDidChange = this._onDidChange.event;
10
- }
11
- canCreateOutline(pane) {
12
- for (const factory of this._factories) {
13
- if (factory.matches(pane)) {
14
- return true;
15
- }
16
- }
17
- return false;
18
- }
19
- async createOutline(pane, target, token) {
20
- for (const factory of this._factories) {
21
- if (factory.matches(pane)) {
22
- return await factory.createOutline(pane, target, token);
23
- }
24
- }
25
- return undefined;
26
- }
27
- registerOutlineCreator(creator) {
28
- const rm = this._factories.push(creator);
29
- this._onDidChange.fire();
30
- return toDisposable(() => {
31
- rm();
32
- this._onDidChange.fire();
33
- });
34
- }
35
- }
36
-
37
- export { OutlineService };