-
Notifications
You must be signed in to change notification settings - Fork 29.4k
/
outlinePanel2.ts
611 lines (534 loc) · 22.1 KB
/
outlinePanel2.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { posix } from 'path';
import * as dom from 'vs/base/browser/dom';
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { ProgressBar } from 'vs/base/browser/ui/progressbar/progressbar';
import { Action, IAction, RadioGroup } from 'vs/base/common/actions';
import { firstIndex } from 'vs/base/common/arrays';
import { createCancelablePromise, TimeoutTimer } from 'vs/base/common/async';
import { isPromiseCanceledError } from 'vs/base/common/errors';
import { Emitter } from 'vs/base/common/event';
import { defaultGenerator } from 'vs/base/common/idGenerator';
import { dispose, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { LRUCache } from 'vs/base/common/map';
import { escape } from 'vs/base/common/strings';
import { URI } from 'vs/base/common/uri';
import 'vs/css!./outlinePanel';
import { ICodeEditor, isCodeEditor, isDiffEditor } from 'vs/editor/browser/editorBrowser';
import { Range } from 'vs/editor/common/core/range';
import { Selection } from 'vs/editor/common/core/selection';
import { ITextModel } from 'vs/editor/common/model';
import { IModelContentChangedEvent } from 'vs/editor/common/model/textModelEvents';
import { DocumentSymbolProviderRegistry } from 'vs/editor/common/modes';
import { LanguageFeatureRegistry } from 'vs/editor/common/modes/languageFeatureRegistry';
import { OutlineElement, OutlineModel, TreeElement } from 'vs/editor/contrib/documentSymbols/outlineModel';
import { localize } from 'vs/nls';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IResourceInput } from 'vs/platform/editor/common/editor';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { WorkbenchDataTree } from 'vs/platform/list/browser/listService';
import { IMarkerService, MarkerSeverity } from 'vs/platform/markers/common/markers';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { attachProgressBarStyler } from 'vs/platform/theme/common/styler';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { ViewletPanel } from 'vs/workbench/browser/parts/views/panelViewlet';
import { IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewlet';
import { CollapseAction2 } from 'vs/workbench/browser/viewlet';
import { ACTIVE_GROUP, IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
import { OutlineConfigKeys, OutlineViewFiltered, OutlineViewFocused } from '../../../../editor/contrib/documentSymbols/outline';
import { FuzzyScore } from 'vs/base/common/filters';
import { NOutlineDataSource, NOutlineItemComparator, NOutlineItemCompareType, NOutlineVirtualDelegate, NOutlineGroupRenderer, NOutlineElementRenderer, NOutlineItem, NOutlineIdentityProvider, NOutlineNavigationLabelProvider } from 'vs/editor/contrib/documentSymbols/outlineTree2';
import { IDataTreeViewState } from 'vs/base/browser/ui/tree/dataTree';
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
class RequestState {
constructor(
private _editorId: string,
private _modelId: string,
private _modelVersion: number,
private _providerCount: number
) {
//
}
equals(other: RequestState): boolean {
return other
&& this._editorId === other._editorId
&& this._modelId === other._modelId
&& this._modelVersion === other._modelVersion
&& this._providerCount === other._providerCount;
}
}
class RequestOracle {
private _disposables = new Array<IDisposable>();
private _sessionDisposable: IDisposable;
private _lastState: RequestState;
constructor(
private readonly _callback: (editor: ICodeEditor, change: IModelContentChangedEvent) => any,
private readonly _featureRegistry: LanguageFeatureRegistry<any>,
@IEditorService private readonly _editorService: IEditorService,
) {
_editorService.onDidActiveEditorChange(this._update, this, this._disposables);
_featureRegistry.onDidChange(this._update, this, this._disposables);
this._update();
}
dispose(): void {
dispose(this._disposables);
dispose(this._sessionDisposable);
}
private _update(): void {
let widget = this._editorService.activeTextEditorWidget;
let codeEditor: ICodeEditor | undefined = undefined;
if (isCodeEditor(widget)) {
codeEditor = widget;
} else if (isDiffEditor(widget)) {
codeEditor = widget.getModifiedEditor();
}
if (!codeEditor || !codeEditor.getModel()) {
this._lastState = undefined;
this._callback(undefined, undefined);
return;
}
let thisState = new RequestState(
codeEditor.getId(),
codeEditor.getModel().id,
codeEditor.getModel().getVersionId(),
this._featureRegistry.all(codeEditor.getModel()).length
);
if (thisState.equals(this._lastState)) {
// prevent unneccesary changes...
return;
}
dispose(this._sessionDisposable);
this._lastState = thisState;
this._callback(codeEditor, undefined);
let handle: any;
let contentListener = codeEditor.onDidChangeModelContent(event => {
clearTimeout(handle);
handle = setTimeout(() => this._callback(codeEditor, event), 350);
});
let modeListener = codeEditor.onDidChangeModelLanguage(_ => {
this._callback(codeEditor, undefined);
});
let disposeListener = codeEditor.onDidDispose(() => {
this._callback(undefined, undefined);
});
this._sessionDisposable = {
dispose() {
contentListener.dispose();
clearTimeout(handle);
modeListener.dispose();
disposeListener.dispose();
}
};
}
}
class SimpleToggleAction extends Action {
constructor(label: string, checked: boolean, callback: (action: SimpleToggleAction) => any, className?: string) {
super(`simple` + defaultGenerator.nextId(), label, className, true, _ => {
this.checked = !this.checked;
callback(this);
return undefined;
});
this.checked = checked;
}
}
class OutlineViewState {
private _followCursor = false;
private _filterOnType = true;
private _sortBy = NOutlineItemCompareType.ByKind;
private _onDidChange = new Emitter<{ followCursor?: boolean, sortBy?: boolean, filterOnType?: boolean }>();
readonly onDidChange = this._onDidChange.event;
set followCursor(value: boolean) {
if (value !== this._followCursor) {
this._followCursor = value;
this._onDidChange.fire({ followCursor: true });
}
}
get followCursor(): boolean {
return this._followCursor;
}
get filterOnType() {
return this._filterOnType;
}
set filterOnType(value) {
if (value !== this._filterOnType) {
this._filterOnType = value;
this._onDidChange.fire({ filterOnType: true });
}
}
set sortBy(value: NOutlineItemCompareType) {
if (value !== this._sortBy) {
this._sortBy = value;
this._onDidChange.fire({ sortBy: true });
}
}
get sortBy(): NOutlineItemCompareType {
return this._sortBy;
}
persist(storageService: IStorageService): void {
storageService.store('outline/state', JSON.stringify({ followCursor: this.followCursor, sortBy: this.sortBy }), StorageScope.WORKSPACE);
}
restore(storageService: IStorageService): void {
let raw = storageService.get('outline/state', StorageScope.WORKSPACE);
if (!raw) {
return;
}
let data: any;
try {
data = JSON.parse(raw);
} catch (e) {
return;
}
this.followCursor = data.followCursor;
this.sortBy = data.sortBy;
}
}
export class OutlinePanel extends ViewletPanel {
private _disposables = new Array<IDisposable>();
private _editorDisposables = new Array<IDisposable>();
private _outlineViewState = new OutlineViewState();
private _requestOracle: RequestOracle;
private _cachedHeight: number;
private _domNode: HTMLElement;
private _message: HTMLDivElement;
private _inputContainer: HTMLDivElement;
private _progressBar: ProgressBar;
private _tree: WorkbenchDataTree<OutlineModel, NOutlineItem, FuzzyScore>;
private _treeDataSource: NOutlineDataSource;
private _treeRenderer: NOutlineElementRenderer;
private _treeComparator: NOutlineItemComparator;
private _treeStates = new LRUCache<string, IDataTreeViewState>(10);
private _treeFakeUIEvent = new UIEvent('me');
private readonly _contextKeyFocused: IContextKey<boolean>;
private readonly _contextKeyFiltered: IContextKey<boolean>;
constructor(
options: IViewletViewOptions,
@IInstantiationService private readonly _instantiationService: IInstantiationService,
@IThemeService private readonly _themeService: IThemeService,
@IStorageService private readonly _storageService: IStorageService,
@IEditorService private readonly _editorService: IEditorService,
@IMarkerService private readonly _markerService: IMarkerService,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@IKeybindingService keybindingService: IKeybindingService,
@IConfigurationService configurationService: IConfigurationService,
@IContextKeyService contextKeyService: IContextKeyService,
@IContextMenuService contextMenuService: IContextMenuService,
) {
super(options, keybindingService, contextMenuService, configurationService);
this._outlineViewState.restore(this._storageService);
this._contextKeyFocused = OutlineViewFocused.bindTo(contextKeyService);
this._contextKeyFiltered = OutlineViewFiltered.bindTo(contextKeyService);
this._disposables.push(this.onDidFocus(_ => this._contextKeyFocused.set(true)));
this._disposables.push(this.onDidBlur(_ => this._contextKeyFocused.set(false)));
}
dispose(): void {
dispose(this._disposables);
dispose(this._requestOracle);
dispose(this._editorDisposables);
super.dispose();
}
focus(): void {
if (this._tree) {
// focus on tree and fallback to root
// dom node when the tree cannot take focus,
// e.g. when hidden
this._tree.domFocus();
if (!this._tree.isDOMFocused()) {
this._domNode.focus();
}
}
}
protected renderBody(container: HTMLElement): void {
this._domNode = container;
this._domNode.tabIndex = 0;
dom.addClass(container, 'outline-panel');
let progressContainer = dom.$('.outline-progress');
this._message = dom.$('.outline-message');
this._inputContainer = dom.$('.outline-input');
this._progressBar = new ProgressBar(progressContainer);
this.disposables.push(attachProgressBarStyler(this._progressBar, this._themeService));
let treeContainer = dom.$('.outline-tree');
dom.append(
container,
progressContainer, this._message, this._inputContainer, treeContainer
);
this._treeRenderer = this._instantiationService.createInstance(NOutlineElementRenderer);
this._treeDataSource = new NOutlineDataSource();
this._treeComparator = new NOutlineItemComparator(this._outlineViewState.sortBy);
this._tree = this._instantiationService.createInstance(
WorkbenchDataTree,
treeContainer,
new NOutlineVirtualDelegate(),
[new NOutlineGroupRenderer(), this._treeRenderer],
this._treeDataSource,
{
filterOnType: this._outlineViewState.filterOnType,
sorter: new NOutlineItemComparator(),
identityProvider: new NOutlineIdentityProvider(),
keyboardNavigationLabelProvider: this._instantiationService.createInstance(NOutlineNavigationLabelProvider)
}
) as WorkbenchDataTree<OutlineModel, NOutlineItem, FuzzyScore>;
this._treeRenderer.renderProblemColors = this._configurationService.getValue(OutlineConfigKeys.problemsColors);
this._treeRenderer.renderProblemBadges = this._configurationService.getValue(OutlineConfigKeys.problemsBadges);
this._disposables.push(this._tree);
this._disposables.push(this._outlineViewState.onDidChange(this._onDidChangeUserState, this));
// feature: toggle icons
this.disposables.push(this._configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration(OutlineConfigKeys.icons)) {
this._tree.updateChildren();
}
}));
this.disposables.push(this.onDidChangeBodyVisibility(visible => {
if (visible && !this._requestOracle) {
this._requestOracle = this._instantiationService.createInstance(RequestOracle, (editor, event) => this._doUpdate(editor, event), DocumentSymbolProviderRegistry);
} else if (!visible) {
dispose(this._requestOracle);
this._requestOracle = undefined;
this._doUpdate(undefined, undefined);
}
}));
}
protected layoutBody(height: number): void {
if (height !== this._cachedHeight) {
this._tree.layout(height);
}
}
getActions(): IAction[] {
return [
new Action('collapse', localize('collapse', "Collapse All"), 'explorer-action collapse-explorer', true, () => {
return new CollapseAction2(this._tree, true, undefined).run();
})
];
}
getSecondaryActions(): IAction[] {
let group = new RadioGroup([
new SimpleToggleAction(localize('sortByPosition', "Sort By: Position"), this._outlineViewState.sortBy === NOutlineItemCompareType.ByPosition, _ => this._outlineViewState.sortBy = NOutlineItemCompareType.ByPosition),
new SimpleToggleAction(localize('sortByName', "Sort By: Name"), this._outlineViewState.sortBy === NOutlineItemCompareType.ByName, _ => this._outlineViewState.sortBy = NOutlineItemCompareType.ByName),
new SimpleToggleAction(localize('sortByKind', "Sort By: Type"), this._outlineViewState.sortBy === NOutlineItemCompareType.ByKind, _ => this._outlineViewState.sortBy = NOutlineItemCompareType.ByKind),
]);
let result = [
new SimpleToggleAction(localize('followCur', "Follow Cursor"), this._outlineViewState.followCursor, action => this._outlineViewState.followCursor = action.checked),
new SimpleToggleAction(localize('filterOnType', "Filter on Type"), this._outlineViewState.filterOnType, action => this._outlineViewState.filterOnType = action.checked),
new Separator(),
...group.actions,
];
this.disposables.push(...result);
this.disposables.push(group);
return result;
}
private _onDidChangeUserState(e: { followCursor?: boolean, sortBy?: boolean, filterOnType?: boolean }) {
this._outlineViewState.persist(this._storageService);
if (e.followCursor) {
// todo@joh update immediately
}
if (e.sortBy) {
this._treeComparator.type = this._outlineViewState.sortBy;
// todo@joh resort
// this._tree.refresh(undefined, true);
this._tree.updateChildren();
}
if (e.filterOnType) {
this._tree.updateOptions({
filterOnType: this._outlineViewState.filterOnType
});
}
}
private _showMessage(message: string) {
dom.addClass(this._domNode, 'message');
this._tree.setInput(undefined);
this._progressBar.stop().hide();
this._message.innerText = escape(message);
}
private static _createOutlineModel(model: ITextModel, disposables: IDisposable[]): Promise<OutlineModel> {
let promise = createCancelablePromise(token => OutlineModel.create(model, token));
disposables.push({ dispose() { promise.cancel(); } });
return promise.catch(err => {
if (!isPromiseCanceledError(err)) {
throw err;
}
return undefined;
});
}
private async _doUpdate(editor: ICodeEditor, event: IModelContentChangedEvent): Promise<void> {
dispose(this._editorDisposables);
this._editorDisposables = new Array();
this._progressBar.infinite().show(150);
if (!editor || !DocumentSymbolProviderRegistry.has(editor.getModel())) {
return this._showMessage(localize('no-editor', "There are no editors open that can provide outline information."));
}
let textModel = editor.getModel();
let loadingMessage: IDisposable;
let oldModel = <OutlineModel>this._tree.getInput();
if (!oldModel) {
loadingMessage = new TimeoutTimer(
() => this._showMessage(localize('loading', "Loading document symbols for '{0}'...", posix.basename(textModel.uri.path))),
100
);
}
let model = await OutlinePanel._createOutlineModel(textModel, this._editorDisposables);
dispose(loadingMessage);
if (!model) {
return;
}
if (TreeElement.empty(model)) {
return this._showMessage(localize('no-symbols', "No symbols found in document '{0}'", posix.basename(textModel.uri.path)));
}
let newSize = TreeElement.size(model);
if (newSize > 7500) {
// this is a workaround for performance issues with the tree: https://github.com/Microsoft/vscode/issues/18180
return this._showMessage(localize('too-many-symbols', "We are sorry, but this file is too large for showing an outline."));
}
dom.removeClass(this._domNode, 'message');
if (event && oldModel && textModel.getLineCount() >= 25) {
// heuristic: when the symbols-to-lines ratio changes by 50% between edits
// wait a little (and hope that the next change isn't as drastic).
let newLength = textModel.getValueLength();
let newRatio = newSize / newLength;
let oldSize = TreeElement.size(oldModel);
let oldLength = newLength - event.changes.reduce((prev, value) => prev + value.rangeLength, 0);
let oldRatio = oldSize / oldLength;
if (newRatio <= oldRatio * 0.5 || newRatio >= oldRatio * 1.5) {
let waitPromise = new Promise<boolean>(resolve => {
let handle = setTimeout(() => {
handle = undefined;
resolve(true);
}, 2000);
this._disposables.push({
dispose() {
clearTimeout(handle);
resolve(false);
}
});
});
if (!await waitPromise) {
return;
}
}
}
this._progressBar.stop().hide();
if (oldModel && oldModel.merge(model)) {
this._tree.updateChildren();
model = oldModel;
} else {
// persist state
if (oldModel) {
let state = this._tree.getViewState();
this._treeStates.set(oldModel.textModel.uri.toString(), state);
}
let state = this._treeStates.get(model.textModel.uri.toString());
await this._tree.setInput(model, state);
}
this.layoutBody(this._cachedHeight);
// transfer focus from domNode to the tree
if (this._domNode === document.activeElement) {
this._tree.domFocus();
}
this._editorDisposables.push(toDisposable(() => this._contextKeyFiltered.reset()));
// feature: reveal outline selection in editor
// on change -> reveal/select defining range
this._editorDisposables.push(this._tree.onDidChangeSelection(e => {
if (e.browserEvent === this._treeFakeUIEvent /* || e.payload && e.payload.didClickOnTwistie */) {
return;
}
let [first] = e.elements;
if (!(first instanceof OutlineElement)) {
return;
}
let focus = false;
let aside = false;
// todo@Joh
if (e.browserEvent) {
if (e.browserEvent.type === 'keydown') {
focus = true;
} else if (e.browserEvent.type === 'click') {
const event = new StandardMouseEvent(e.browserEvent as MouseEvent);
focus = e.browserEvent.detail === 2;
aside = (!this._tree.useAltAsMultipleSelectionModifier && event.altKey)
|| (this._tree.useAltAsMultipleSelectionModifier && (event.ctrlKey || event.metaKey));
}
}
this._revealTreeSelection(model, first, focus, aside);
}));
// feature: reveal editor selection in outline
this._revealEditorSelection(model, editor.getSelection());
const versionIdThen = model.textModel.getVersionId();
this._editorDisposables.push(editor.onDidChangeCursorSelection(e => {
// first check if the document has changed and stop revealing the
// cursor position iff it has -> we will update/recompute the
// outline view then anyways
if (!model.textModel.isDisposed() && model.textModel.getVersionId() === versionIdThen) {
this._revealEditorSelection(model, e.selection);
}
}));
// feature: show markers in outline
const updateMarker = (e: URI[], ignoreEmpty?: boolean) => {
if (!this._configurationService.getValue(OutlineConfigKeys.problemsEnabled)) {
return;
}
if (firstIndex(e, a => a.toString() === textModel.uri.toString()) < 0) {
return;
}
const marker = this._markerService.read({ resource: textModel.uri, severities: MarkerSeverity.Error | MarkerSeverity.Warning });
if (marker.length > 0 || !ignoreEmpty) {
model.updateMarker(marker);
this._tree.updateChildren();
// this._tree.refresh(undefined, true);
}
};
updateMarker([textModel.uri], true);
this._editorDisposables.push(this._markerService.onMarkerChanged(updateMarker));
this._editorDisposables.push(this.configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration(OutlineConfigKeys.problemsBadges) || e.affectsConfiguration(OutlineConfigKeys.problemsColors)) {
this._treeRenderer.renderProblemColors = this._configurationService.getValue(OutlineConfigKeys.problemsColors);
this._treeRenderer.renderProblemBadges = this._configurationService.getValue(OutlineConfigKeys.problemsBadges);
this._tree.updateChildren();
return;
}
if (!e.affectsConfiguration(OutlineConfigKeys.problemsEnabled)) {
return;
}
if (!this._configurationService.getValue(OutlineConfigKeys.problemsEnabled)) {
model.updateMarker([]);
this._tree.updateChildren();
} else {
updateMarker([textModel.uri], true);
}
}));
}
private async _revealTreeSelection(model: OutlineModel, element: OutlineElement, focus: boolean, aside: boolean): Promise<void> {
await this._editorService.openEditor({
resource: model.textModel.uri,
options: {
preserveFocus: !focus,
selection: Range.collapseToStart(element.symbol.selectionRange),
revealInCenterIfOutsideViewport: true
}
} as IResourceInput, aside ? SIDE_GROUP : ACTIVE_GROUP);
}
private async _revealEditorSelection(model: OutlineModel, selection: Selection): Promise<void> {
if (!this._outlineViewState.followCursor || !this._tree.getInput() || !selection) {
return;
}
let [first] = this._tree.getSelection();
let item = model.getItemEnclosingPosition({
lineNumber: selection.selectionStartLineNumber,
column: selection.selectionStartColumn
}, first instanceof OutlineElement ? first : undefined);
if (!item) {
// nothing to reveal
return;
}
let top = this._tree.getRelativeTop(item);
if (top < 0 || top > 1) {
// only when outside view port
await this._tree.reveal(item, 0.5);
}
this._tree.setFocus([item], this._treeFakeUIEvent);
this._tree.setSelection([item], this._treeFakeUIEvent);
}
}