提交 a7890e19 编写于 作者: A Alex Dima

Toggle Render Whitespace writes to user settings (#18210)

上级 b70f67c2
......@@ -4,3 +4,4 @@
*--------------------------------------------------------------------------------------------*/
import './electron-browser/toggleWordWrap';
import './electron-browser/toggleRenderWhitespace';
/*---------------------------------------------------------------------------------------------
* 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 ToggleRenderWhitespaceAction extends EditorAction {
constructor() {
super({
id: 'editor.action.toggleRenderWhitespace',
label: nls.localize('toggleRenderWhitespace', "Toggle Render Whitespace"),
alias: 'Toggle Render Whitespace',
precondition: null
});
}
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
const configurationEditingService = accessor.get(IConfigurationEditingService);
const messageService = accessor.get(IMessageService);
let renderWhitespace = editor.getConfiguration().viewInfo.renderWhitespace;
let newRenderWhitespace: string;
if (renderWhitespace === 'none') {
newRenderWhitespace = 'all';
} else {
newRenderWhitespace = 'none';
}
configurationEditingService.writeConfiguration(ConfigurationTarget.USER, { key: 'editor.renderWhitespace', value: newRenderWhitespace }).then(null, error => {
messageService.show(Severity.Error, error);
});
}
}
......@@ -28,8 +28,8 @@ class ToggleWordWrapAction extends EditorAction {
}
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
let configurationEditingService = accessor.get(IConfigurationEditingService);
let messageService = accessor.get(IMessageService);
const configurationEditingService = accessor.get(IConfigurationEditingService);
const messageService = accessor.get(IMessageService);
let wrappingInfo = editor.getConfiguration().wrappingInfo;
let newWordWrap: boolean;
......
......@@ -161,31 +161,7 @@ export class DetectIndentation extends EditorAction {
}
}
@editorAction
export class ToggleRenderWhitespaceAction extends EditorAction {
constructor() {
super({
id: 'editor.action.toggleRenderWhitespace',
label: nls.localize('toggleRenderWhitespace', "Toggle Render Whitespace"),
alias: 'Toggle Render Whitespace',
precondition: null
});
}
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void {
let renderWhitespace = editor.getConfiguration().viewInfo.renderWhitespace;
if (renderWhitespace === 'none') {
editor.updateOptions({
renderWhitespace: 'all'
});
} else {
editor.updateOptions({
renderWhitespace: 'none'
});
}
}
}
@editorAction
export class ToggleRenderControlCharacterAction extends EditorAction {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册