Since wrap with abbr is not supported in css, it can fallback to html

This commit is contained in:
Ramya Achutha Rao 2017-08-01 18:23:39 -07:00
parent cdcadccc37
commit e73bb91dc1
7 changed files with 12 additions and 44 deletions

View file

@ -78,6 +78,11 @@
}
},
"commands": [
{
"command": "editor.emmet.action.wrapWithAbbreviation",
"title": "%command.wrapWithAbbreviation%",
"category": "Emmet"
},
{
"command": "editor.emmet.action.removeTag",
"title": "%command.removeTag%",
@ -193,7 +198,7 @@
"vscode": "1.0.1"
},
"dependencies": {
"@emmetio/html-matcher": "^0.3.1",
"@emmetio/css-parser": "^0.3.0",
"@emmetio/math-expression": "^0.1.1",

View file

@ -1,4 +1,5 @@
{
"command.wrapWithAbbreviation": "Wrap with Abbreviation",
"command.removeTag": "Remove Tag",
"command.updateTag": "Update Tag",
"command.matchTag": "Go to Matching Pair",

View file

@ -17,13 +17,13 @@ interface ExpandAbbreviationInput {
}
export function wrapWithAbbreviation(args) {
const syntax = getSyntaxFromArgs(args);
if (!syntax || !validate()) {
if (!validate(false)) {
return;
}
const editor = vscode.window.activeTextEditor;
const abbreviationPromise = (args && args['abbreviation']) ? Promise.resolve(args['abbreviation']) : vscode.window.showInputBox({ prompt: 'Enter Abbreviation' });
const syntax = getSyntaxFromArgs({ language: editor.document.languageId }) || 'html';
return abbreviationPromise.then(abbreviation => {
if (!abbreviation || !abbreviation.trim() || !isAbbreviationValid(syntax, abbreviation)) { return; }

View file

@ -27,7 +27,7 @@ import * as path from 'path';
export function activate(context: vscode.ExtensionContext) {
registerCompletionProviders(context, true);
context.subscriptions.push(vscode.commands.registerCommand('emmet.wrapWithAbbreviation', (args) => {
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.wrapWithAbbreviation', (args) => {
wrapWithAbbreviation(args);
}));

View file

@ -1,27 +0,0 @@
/*---------------------------------------------------------------------------------------------
* 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 nls = require('vs/nls');
import { EmmetEditorAction } from 'vs/workbench/parts/emmet/electron-browser/emmetActions';
import { editorAction } from 'vs/editor/common/editorCommonExtensions';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
@editorAction
class WrapWithAbbreviationAction extends EmmetEditorAction {
constructor() {
super({
id: 'editor.emmet.action.wrapWithAbbreviation',
label: nls.localize('wrapWithAbbreviationAction', "Emmet: Wrap with Abbreviation"),
alias: 'Emmet: Wrap with Abbreviation',
precondition: EditorContextKeys.writable,
actionName: 'wrap_with_abbreviation'
});
}
}

View file

@ -6,5 +6,4 @@
'use strict';
import './actions/expandAbbreviation';
import './actions/wrapWithAbbreviation';

View file

@ -57,11 +57,6 @@ export interface IEmmetActionOptions extends IActionOptions {
export abstract class EmmetEditorAction extends EditorAction {
private actionMap = {
'editor.emmet.action.wrapWithAbbreviation': 'emmet.wrapWithAbbreviation',
'editor.emmet.action.expandAbbreviation': 'emmet.expandAbbreviation'
};
protected emmetActionName: string;
constructor(opts: IEmmetActionOptions) {
@ -88,15 +83,10 @@ export abstract class EmmetEditorAction extends EditorAction {
const modeService = accessor.get(IModeService);
const commandService = accessor.get(ICommandService);
let mappedCommand = this.actionMap[this.id];
if (mappedCommand && mappedCommand !== 'emmet.expandAbbreviation' && mappedCommand !== 'emmet.wrapWithAbbreviation') {
return commandService.executeCommand<void>(mappedCommand);
}
return this._withGrammarContributions(extensionService).then((grammarContributions) => {
if (mappedCommand === 'emmet.expandAbbreviation' || mappedCommand === 'emmet.wrapWithAbbreviation') {
return commandService.executeCommand<void>(mappedCommand, EmmetEditorAction.getLanguage(modeService, editor, grammarContributions));
if (this.id === 'editor.emmet.action.expandAbbreviation') {
return commandService.executeCommand<void>('emmet.expandAbbreviation', EmmetEditorAction.getLanguage(modeService, editor, grammarContributions));
}
return undefined;