提交 7f48a9b8 编写于 作者: E Erich Gamma

Tweaked the PR

上级 479470f9
......@@ -9,7 +9,6 @@ import nls = require('vs/nls');
import {BasicEmmetEditorAction} from 'vs/workbench/parts/emmet/node/emmetActions';
import {CommonEditorRegistry, EditorActionDescriptor} from 'vs/editor/common/editorCommonExtensions';
import {IEditorActionDescriptorData, ICommonCodeEditor} from 'vs/editor/common/editorCommon';
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
import editorCommon = require('vs/editor/common/editorCommon');
......@@ -21,9 +20,14 @@ class ExpandAbbreviationAction extends BasicEmmetEditorAction {
static ID = 'editor.emmet.action.expandAbbreviation';
constructor(descriptor: IEditorActionDescriptorData, editor: ICommonCodeEditor, @IConfigurationService configurationService: IConfigurationService) {
constructor(descriptor: editorCommon.IEditorActionDescriptorData, editor: editorCommon.ICommonCodeEditor, @IConfigurationService configurationService: IConfigurationService) {
super(descriptor, editor, configurationService, 'expand_abbreviation');
}
public noExpansionOccurred(actionId?: string): void {
// forward the tab key back to the editor
this.editor.trigger('emmet', editorCommon.Handler.Tab, {});
}
}
CommonEditorRegistry.registerEditorAction(new EditorActionDescriptor(ExpandAbbreviationAction,
......
......@@ -23,13 +23,6 @@ export class EditorAccessor implements emmet.Editor {
this.editor = editor;
}
public noExpansionOccurred(actionId?: string): void {
// return the tab key handling back to the editor only for Expand Abbreviation command
if (actionId === 'editor.emmet.action.expandAbbreviation') {
this.editor.trigger('emmet', Handler.Tab, {});
}
}
public isEmmetEnabledMode(): boolean {
let syntax = this.getSyntax();
return (this.emmetSupportedModes.indexOf(syntax) !== -1);
......
......@@ -61,6 +61,10 @@ export abstract class EmmetEditorAction extends EditorAction {
abstract runEmmetAction(_emmet: any);
protected noExpansionOccurred() {
// default do nothing
}
public run(): TPromise<boolean> {
return new TPromise((c, e) => {
require(['emmet'], (_emmet) => {
......@@ -68,7 +72,7 @@ export abstract class EmmetEditorAction extends EditorAction {
try {
if (!this.editorAccessor.isEmmetEnabledMode()) {
this.editorAccessor.noExpansionOccurred(this.id);
this.noExpansionOccurred();
return;
}
this.updateEmmetPreferences(_emmet);
......@@ -95,7 +99,7 @@ export class BasicEmmetEditorAction extends EmmetEditorAction {
public runEmmetAction(_emmet) {
if (!_emmet.run(this.emmetActionName, this.editorAccessor)) {
this.editorAccessor.noExpansionOccurred();
this.noExpansionOccurred();
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册