mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
Toggle Render Control Characters writes to user settings (#18210)
This commit is contained in:
@@ -3,5 +3,6 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import './electron-browser/toggleWordWrap';
|
||||
import './electron-browser/toggleRenderControlCharacter';
|
||||
import './electron-browser/toggleRenderWhitespace';
|
||||
import './electron-browser/toggleWordWrap';
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import { ICommonCodeEditor } from 'vs/editor/common/editorCommon';
|
||||
import { editorAction, ServicesAccessor, EditorAction } from 'vs/editor/common/editorCommonExtensions';
|
||||
import { IConfigurationEditingService, ConfigurationTarget } from 'vs/workbench/services/configuration/common/configurationEditing';
|
||||
import { IMessageService, Severity } from 'vs/platform/message/common/message';
|
||||
|
||||
@editorAction
|
||||
export class ToggleRenderControlCharacterAction extends EditorAction {
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
id: 'editor.action.toggleRenderControlCharacter',
|
||||
label: nls.localize('toggleRenderControlCharacters', "Toggle Control Characters"),
|
||||
alias: 'Toggle Render Control Characters',
|
||||
precondition: null
|
||||
});
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
|
||||
const configurationEditingService = accessor.get(IConfigurationEditingService);
|
||||
const messageService = accessor.get(IMessageService);
|
||||
|
||||
let newRenderControlCharacters = !editor.getConfiguration().viewInfo.renderControlCharacters;
|
||||
|
||||
configurationEditingService.writeConfiguration(ConfigurationTarget.USER, { key: 'editor.renderControlCharacters', value: newRenderControlCharacters }).then(null, error => {
|
||||
messageService.show(Severity.Error, error);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -160,24 +160,3 @@ export class DetectIndentation extends EditorAction {
|
||||
model.detectIndentation(creationOpts.insertSpaces, creationOpts.tabSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@editorAction
|
||||
export class ToggleRenderControlCharacterAction extends EditorAction {
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
id: 'editor.action.toggleRenderControlCharacter',
|
||||
label: nls.localize('toggleRenderControlCharacters', "Toggle Control Characters"),
|
||||
alias: 'Toggle Render Control Characters',
|
||||
precondition: null
|
||||
});
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
|
||||
editor.updateOptions({
|
||||
renderControlCharacters: !editor.getConfiguration().viewInfo.renderControlCharacters
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user