Skip to content

Commit

Permalink
core: add toggle breadcrumbs command
Browse files Browse the repository at this point in the history
The commit adds the command `Toggle Breadcrumbs` to control the enablement of the `breadcrumbs.enabled` preference.
The changes also including adding an entry under the top-level `View` menu.

Signed-off-by: vince-fugnitto <[email protected]>
  • Loading branch information
vince-fugnitto committed Aug 15, 2022
1 parent 2293a5b commit c26f12e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
21 changes: 20 additions & 1 deletion packages/core/src/browser/common-frontend-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { ColorRegistry } from './color-registry';
import { Color } from '../common/color';
import { CoreConfiguration, CorePreferences } from './core-preferences';
import { ThemeService } from './theming';
import { PreferenceService, PreferenceChangeEvent } from './preferences';
import { PreferenceService, PreferenceChangeEvent, PreferenceScope } from './preferences';
import { ClipboardService } from './clipboard-service';
import { EncodingRegistry } from './encoding-registry';
import { UTF8 } from '../common/encodings';
Expand Down Expand Up @@ -330,6 +330,12 @@ export namespace CommonCommands {
id: 'workbench.action.configureLanguage',
label: 'Configure Display Language'
});

export const TOGGLE_BREADCRUMBS = Command.toDefaultLocalizedCommand({
id: 'breadcrumbs.toggle',
label: 'Toggle Breadcrumbs',
category: VIEW_CATEGORY
});
}

export const supportCut = browser.isNative || document.queryCommandSupported('cut');
Expand Down Expand Up @@ -931,6 +937,10 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
commandRegistry.registerCommand(CommonCommands.CONFIGURE_DISPLAY_LANGUAGE, {
execute: () => this.configureDisplayLanguage()
});
commandRegistry.registerCommand(CommonCommands.TOGGLE_BREADCRUMBS, {
execute: () => this.toggleBreadcrumbs(),
isToggled: () => this.isBreadcrumbsEnabled(),
});
commandRegistry.registerCommand(CommonCommands.NEW_UNTITLED_FILE, {
execute: async () => {
const untitledUri = this.untitledResourceResolver.createUntitledURI('', await this.workingDirProvider.getUserWorkingDir());
Expand Down Expand Up @@ -1150,6 +1160,15 @@ export class CommonFrontendContribution implements FrontendApplicationContributi
}
}

protected toggleBreadcrumbs(): void {
const value: boolean | undefined = this.preferenceService.get('breadcrumbs.enabled');
this.preferenceService.set('breadcrumbs.enabled', !value, PreferenceScope.User);
}

protected isBreadcrumbsEnabled(): boolean {
return !!this.preferenceService.get('breadcrumbs.enabled');
}

protected async confirmRestart(): Promise<boolean> {
const shouldRestart = await new ConfirmDialog({
title: nls.localizeByDefault('A restart is required for the change in display language to take effect.'),
Expand Down
9 changes: 5 additions & 4 deletions packages/editor/src/browser/editor-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,19 @@ export class EditorMenuContribution implements MenuContribution {
// Toggle Commands.
registry.registerMenuAction(CommonMenus.VIEW_TOGGLE, {
commandId: EditorCommands.TOGGLE_WORD_WRAP.id,
label: EditorCommands.TOGGLE_WORD_WRAP.label,
order: '0'
});
registry.registerMenuAction(CommonMenus.VIEW_TOGGLE, {
commandId: EditorCommands.TOGGLE_MINIMAP.id,
label: EditorCommands.TOGGLE_MINIMAP.label,
order: '1',
});
registry.registerMenuAction(CommonMenus.VIEW_TOGGLE, {
commandId: CommonCommands.TOGGLE_BREADCRUMBS.id,
order: '2',
});
registry.registerMenuAction(CommonMenus.VIEW_TOGGLE, {
commandId: EditorCommands.TOGGLE_RENDER_WHITESPACE.id,
label: EditorCommands.TOGGLE_RENDER_WHITESPACE.label,
order: '2'
order: '3'
});
registry.registerMenuAction(CommonMenus.FILE_CLOSE, {
commandId: CommonCommands.CLOSE_MAIN_TAB.id,
Expand Down

0 comments on commit c26f12e

Please sign in to comment.