提交 f01ee985 编写于 作者: I isidor

indentation: actions

上级 481ec6ac
......@@ -38,7 +38,8 @@ define([
'vs/editor/contrib/wordHighlighter/common/wordHighlighter',
'vs/editor/contrib/workerStatusReporter/browser/workerStatusReporter',
'vs/editor/contrib/defineKeybinding/browser/defineKeybinding',
"vs/editor/contrib/folding/browser/folding",
'vs/editor/contrib/folding/browser/folding',
'vs/editor/contrib/indentation/common/indentation',
// include these in the editor bundle because they are widely used by many languages
'vs/editor/common/languages.common'
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import nls = require('vs/nls');
import {TPromise} from 'vs/base/common/winjs.base';
import {CommonEditorRegistry, EditorActionDescriptor} from 'vs/editor/common/editorCommonExtensions';
import {EditorAction} from 'vs/editor/common/editorAction';
import EditorCommon = require('vs/editor/common/editorCommon');
import {IndentationToTabsCommand, IndentationToSpacesCommand} from 'vs/editor/contrib/indentation/common/indentationCommands';
import {INullService} from 'vs/platform/instantiation/common/instantiation';
class IndentationToSpacesAction extends EditorAction {
static ID = 'editor.action.indentationToSpaces';
constructor(descriptor: EditorCommon.IEditorActionDescriptorData, editor: EditorCommon.ICommonCodeEditor, @INullService ns) {
super(descriptor, editor);
}
public run(): TPromise<boolean> {
const command = new IndentationToSpacesCommand(this.editor.getSelection(), this.editor.getIndentationOptions().tabSize);
this.editor.executeCommands(this.id, [command]);
return TPromise.as(true);
}
}
class IndentationToTabsAction extends EditorAction {
static ID = 'editor.action.indentationToTabs';
constructor(descriptor: EditorCommon.IEditorActionDescriptorData, editor: EditorCommon.ICommonCodeEditor, @INullService ns) {
super(descriptor, editor);
}
public run(): TPromise<boolean> {
const command = new IndentationToTabsCommand(this.editor.getSelection(), this.editor.getIndentationOptions().tabSize);
this.editor.executeCommands(this.id, [command]);
return TPromise.as(true);
}
}
// register actions
CommonEditorRegistry.registerEditorAction(new EditorActionDescriptor(IndentationToSpacesAction, IndentationToSpacesAction.ID, nls.localize('indentationToSpaces', "Convert Indentation to Spaces")));
CommonEditorRegistry.registerEditorAction(new EditorActionDescriptor(IndentationToTabsAction, IndentationToTabsAction.ID, nls.localize('indentationToTabs', "Convert Indentation to Tabs")));
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册