Path: blob/main/src/vs/workbench/contrib/codeEditor/browser/toggleRenderControlCharacter.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { localize, localize2 } from '../../../../nls.js';6import { Action2, MenuId, registerAction2 } from '../../../../platform/actions/common/actions.js';7import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';8import { ContextKeyExpr } from '../../../../platform/contextkey/common/contextkey.js';9import { Categories } from '../../../../platform/action/common/actionCommonCategories.js';10import { ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js';1112export class ToggleRenderControlCharacterAction extends Action2 {1314static readonly ID = 'editor.action.toggleRenderControlCharacter';1516constructor() {17super({18id: ToggleRenderControlCharacterAction.ID,19title: {20...localize2('toggleRenderControlCharacters', "Toggle Control Characters"),21mnemonicTitle: localize({ key: 'miToggleRenderControlCharacters', comment: ['&& denotes a mnemonic'] }, "Render &&Control Characters"),22},23category: Categories.View,24f1: true,25toggled: ContextKeyExpr.equals('config.editor.renderControlCharacters', true),26menu: {27id: MenuId.MenubarAppearanceMenu,28group: '4_editor',29order: 530}31});32}3334override run(accessor: ServicesAccessor): Promise<void> {35const configurationService = accessor.get(IConfigurationService);3637const newRenderControlCharacters = !configurationService.getValue<boolean>('editor.renderControlCharacters');38return configurationService.updateValue('editor.renderControlCharacters', newRenderControlCharacters);39}40}4142registerAction2(ToggleRenderControlCharacterAction);434445