Skip to content

Commit

Permalink
Add 'breadcrumbs.enabled' configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Cornelius A. Ludmann <[email protected]>
  • Loading branch information
corneliusludmann committed Oct 19, 2019
1 parent 03eb644 commit 3dee5ec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/core/src/browser/breadcrumbs/breadcrumbs-renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import PerfectScrollbar from 'perfect-scrollbar';
import URI from '../../common/uri';
import { BreadcrumbPopup } from './breadcrumb-popup';
import { DisposableCollection } from '../../common/disposable';
import { CorePreferences } from '../core-preferences';

export const BreadcrumbsURI = Symbol('BreadcrumbsURI');

Expand All @@ -39,6 +40,9 @@ export class BreadcrumbsRenderer extends ReactRenderer {
@inject(BreadcrumbRenderer)
protected readonly breadcrumbRenderer: BreadcrumbRenderer;

@inject(CorePreferences)
protected readonly corePreferences: CorePreferences;

private breadcrumbs: Breadcrumb[] = [];

private popup: BreadcrumbPopup | undefined;
Expand All @@ -54,6 +58,7 @@ export class BreadcrumbsRenderer extends ReactRenderer {
@postConstruct()
init(): void {
this.toDispose.push(this.breadcrumbsService.onBreadcrumbsChange(uri => { if (this.uri.toString() === uri.toString()) { this.refresh(); } }));
this.toDispose.push(this.corePreferences.onPreferenceChanged(_ => this.refresh()));
}

dispose(): void {
Expand All @@ -67,7 +72,11 @@ export class BreadcrumbsRenderer extends ReactRenderer {
}

async refresh(): Promise<void> {
this.breadcrumbs = await this.breadcrumbsService.getBreadcrumbs(this.uri);
if (this.corePreferences['breadcrumbs.enabled']) {
this.breadcrumbs = await this.breadcrumbsService.getBreadcrumbs(this.uri);
} else {
this.breadcrumbs = [];
}
this.render();

if (!this.scrollbar) {
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/browser/core-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ export const corePreferenceSchema: PreferenceSchema = {
default: 50,
minimum: 0,
description: 'Controls the number of recently used commands to keep in history for the command palette. Set to 0 to disable command history.'
},
'breadcrumbs.enabled': {
'type': 'boolean',
'default': true,
'description': 'Enable/disable navigation breadcrumbs.'
}
}
};
Expand All @@ -52,6 +57,7 @@ export interface CoreConfiguration {
'application.confirmExit': 'never' | 'ifRequired' | 'always';
'list.openMode': 'singleClick' | 'doubleClick';
'workbench.commandPalette.history': number;
'breadcrumbs.enabled': boolean;
}

export const CorePreferences = Symbol('CorePreferences');
Expand Down

0 comments on commit 3dee5ec

Please sign in to comment.