mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 13:29:44 +00:00
Since wrap with abbr is not supported in css, it can fallback to html
This commit is contained in:
parent
cdcadccc37
commit
e73bb91dc1
|
@ -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",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"command.wrapWithAbbreviation": "Wrap with Abbreviation",
|
||||
"command.removeTag": "Remove Tag",
|
||||
"command.updateTag": "Update Tag",
|
||||
"command.matchTag": "Go to Matching Pair",
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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);
|
||||
}));
|
||||
|
||||
|
|
|
@ -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'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -6,5 +6,4 @@
|
|||
'use strict';
|
||||
|
||||
import './actions/expandAbbreviation';
|
||||
import './actions/wrapWithAbbreviation';
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue