From 7f48a9b8dd9a33a560af9afe1914e3873fec1f77 Mon Sep 17 00:00:00 2001 From: Erich Gamma Date: Wed, 29 Jun 2016 16:12:29 +0200 Subject: [PATCH] Tweaked the PR --- .../parts/emmet/node/actions/expandAbbreviation.ts | 8 ++++++-- src/vs/workbench/parts/emmet/node/editorAccessor.ts | 7 ------- src/vs/workbench/parts/emmet/node/emmetActions.ts | 8 ++++++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/vs/workbench/parts/emmet/node/actions/expandAbbreviation.ts b/src/vs/workbench/parts/emmet/node/actions/expandAbbreviation.ts index 33dd52d645e..0efafcd94cc 100644 --- a/src/vs/workbench/parts/emmet/node/actions/expandAbbreviation.ts +++ b/src/vs/workbench/parts/emmet/node/actions/expandAbbreviation.ts @@ -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, diff --git a/src/vs/workbench/parts/emmet/node/editorAccessor.ts b/src/vs/workbench/parts/emmet/node/editorAccessor.ts index 271418bfce3..ddb79fae887 100644 --- a/src/vs/workbench/parts/emmet/node/editorAccessor.ts +++ b/src/vs/workbench/parts/emmet/node/editorAccessor.ts @@ -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); diff --git a/src/vs/workbench/parts/emmet/node/emmetActions.ts b/src/vs/workbench/parts/emmet/node/emmetActions.ts index e4383c62dff..b9aec1bfb21 100644 --- a/src/vs/workbench/parts/emmet/node/emmetActions.ts +++ b/src/vs/workbench/parts/emmet/node/emmetActions.ts @@ -61,6 +61,10 @@ export abstract class EmmetEditorAction extends EditorAction { abstract runEmmetAction(_emmet: any); + protected noExpansionOccurred() { + // default do nothing + } + public run(): TPromise { 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(); } } } -- GitLab