Skip to content

Commit

Permalink
Merge pull request microsoft#164706 from microsoft/joh/defiant-wallaby
Browse files Browse the repository at this point in the history
joh/defiant wallaby
  • Loading branch information
jrieken authored and formigoni committed Oct 27, 2022
2 parents 7963a54 + 46e34b5 commit 9baf5ea
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { Emitter, Event } from 'vs/base/common/event';
import { Disposable, DisposableStore, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { IBreadcrumbsDataSource, IOutline, IOutlineCreator, IOutlineListConfig, IOutlineService, OutlineChangeEvent, OutlineConfigKeys, OutlineTarget, } from 'vs/workbench/services/outline/browser/outline';
import { OutlineConfigCollapseItemsValues, IBreadcrumbsDataSource, IOutline, IOutlineCreator, IOutlineListConfig, IOutlineService, OutlineChangeEvent, OutlineConfigKeys, OutlineTarget, } from 'vs/workbench/services/outline/browser/outline';
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { Registry } from 'vs/platform/registry/common/platform';
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
Expand Down Expand Up @@ -103,10 +103,6 @@ class DocumentSymbolBreadcrumbsSource implements IBreadcrumbsDataSource<Document
}
}

export const enum DocumentSymbolsOutlineInitialState {
Collapsed = 'alwaysCollapse',
Expanded = 'alwaysExpand'
}

class DocumentSymbolsOutline implements IOutline<DocumentSymbolItem> {

Expand Down Expand Up @@ -161,9 +157,9 @@ class DocumentSymbolsOutline implements IOutline<DocumentSymbolItem> {
}
};
const comparator = new DocumentSymbolComparator();
const initialState = textResourceConfigurationService.getValue<DocumentSymbolsOutlineInitialState>(_editor.getModel()?.uri, OutlineConfigKeys.collapseItems);
const initialState = textResourceConfigurationService.getValue<OutlineConfigCollapseItemsValues>(_editor.getModel()?.uri, OutlineConfigKeys.collapseItems);
const options = {
collapseByDefault: target === OutlineTarget.Breadcrumbs || (target === OutlineTarget.OutlinePane && initialState === DocumentSymbolsOutlineInitialState.Collapsed),
collapseByDefault: target === OutlineTarget.Breadcrumbs || (target === OutlineTarget.OutlinePane && initialState === OutlineConfigCollapseItemsValues.Collapsed),
expandOnlyOnTwistieClick: true,
multipleSelectionSupport: false,
identityProvider: new DocumentSymbolIdentityProvider(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { IThemeService, ThemeIcon } from 'vs/platform/theme/common/themeService'
import { CellRevealType, IActiveNotebookEditor, ICellViewModel, INotebookEditorOptions, INotebookViewCellsUpdateEvent } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
import { NotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookEditor';
import { CellKind } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { IOutline, IOutlineComparator, IOutlineCreator, IOutlineListConfig, IOutlineService, IQuickPickDataSource, IQuickPickOutlineElement, OutlineChangeEvent, OutlineConfigKeys, OutlineTarget } from 'vs/workbench/services/outline/browser/outline';
import { IOutline, IOutlineComparator, IOutlineCreator, IOutlineListConfig, IOutlineService, IQuickPickDataSource, IQuickPickOutlineElement, OutlineChangeEvent, OutlineConfigCollapseItemsValues, OutlineConfigKeys, OutlineTarget } from 'vs/workbench/services/outline/browser/outline';
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { Registry } from 'vs/platform/registry/common/platform';
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
Expand Down Expand Up @@ -285,16 +285,18 @@ class NotebookComparator implements IOutlineComparator<OutlineEntry> {
}
}

export class NotebookCellOutline extends Disposable implements IOutline<OutlineEntry> {
export class NotebookCellOutline implements IOutline<OutlineEntry> {

private readonly _onDidChange = this._register(new Emitter<OutlineChangeEvent>());
private readonly _dispoables = new DisposableStore();

private readonly _onDidChange = new Emitter<OutlineChangeEvent>();

readonly onDidChange: Event<OutlineChangeEvent> = this._onDidChange.event;

private _uri: URI | undefined;
private _entries: OutlineEntry[] = [];
private _activeEntry?: OutlineEntry;
private readonly _entriesDisposables = this._register(new DisposableStore());
private readonly _entriesDisposables = new DisposableStore();

readonly config: IOutlineListConfig<OutlineEntry>;
readonly outlineKind = 'notebookCells';
Expand All @@ -313,8 +315,8 @@ export class NotebookCellOutline extends Disposable implements IOutline<OutlineE
@IConfigurationService private readonly _configurationService: IConfigurationService,
@INotebookExecutionStateService private readonly _notebookExecutionStateService: INotebookExecutionStateService,
) {
super();
const selectionListener = this._register(new MutableDisposable());
const selectionListener = new MutableDisposable();
this._dispoables.add(selectionListener);
const installSelectionListener = () => {
const notebookEditor = _editor.getControl();
if (!notebookEditor?.hasModel()) {
Expand All @@ -335,22 +337,22 @@ export class NotebookCellOutline extends Disposable implements IOutline<OutlineE
}
};

this._register(_editor.onDidChangeModel(() => {
this._dispoables.add(_editor.onDidChangeModel(() => {
this._recomputeState();
installSelectionListener();
}));

this._register(_configurationService.onDidChangeConfiguration(e => {
this._dispoables.add(_configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('notebook.outline.showCodeCells')) {
this._recomputeState();
}
}));

this._register(themeService.onDidFileIconThemeChange(() => {
this._dispoables.add(themeService.onDidFileIconThemeChange(() => {
this._onDidChange.fire({});
}));

this._register(_notebookExecutionStateService.onDidChangeCellExecution(e => {
this._dispoables.add(_notebookExecutionStateService.onDidChangeCellExecution(e => {
if (!!this._editor.textModel && e.affectsNotebook(this._editor.textModel?.uri)) {
this._recomputeState();
}
Expand All @@ -360,7 +362,7 @@ export class NotebookCellOutline extends Disposable implements IOutline<OutlineE
installSelectionListener();

const options: IWorkbenchDataTreeOptions<OutlineEntry, FuzzyScore> = {
collapseByDefault: _target === OutlineTarget.Breadcrumbs,
collapseByDefault: _target === OutlineTarget.Breadcrumbs || (_target === OutlineTarget.OutlinePane && _configurationService.getValue(OutlineConfigKeys.collapseItems) === OutlineConfigCollapseItemsValues.Collapsed),
expandOnlyOnTwistieClick: true,
multipleSelectionSupport: false,
accessibilityProvider: new NotebookOutlineAccessibility(),
Expand Down Expand Up @@ -394,6 +396,12 @@ export class NotebookCellOutline extends Disposable implements IOutline<OutlineE
};
}

dispose(): void {
this._onDidChange.dispose();
this._dispoables.dispose();
this._entriesDisposables.dispose();
}

private _recomputeState(): void {
this._entriesDisposables.clear();
this._activeEntry = undefined;
Expand Down
5 changes: 5 additions & 0 deletions src/vs/workbench/services/outline/browser/outline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,8 @@ export const enum OutlineConfigKeys {
'problemsColors' = 'outline.problems.colors',
'problemsBadges' = 'outline.problems.badges'
}

export const enum OutlineConfigCollapseItemsValues {
Collapsed = 'alwaysCollapse',
Expanded = 'alwaysExpand'
}

0 comments on commit 9baf5ea

Please sign in to comment.