Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: add toggle breadcrumbs command #11548

Merged
merged 1 commit into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -145,18 +145,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