Move non abbr emmet cmds from core to extension #29969

This commit is contained in:
Ramya Achutha Rao 2017-07-26 16:30:50 -07:00
parent cfeac5b418
commit 4cbe0d35ea
10 changed files with 197 additions and 91 deletions

View file

@ -24,7 +24,9 @@
"title": "Emmet",
"properties": {
"emmet.showExpandedAbbreviation": {
"type": ["string"],
"type": [
"string"
],
"enum": [
"never",
"always",
@ -43,7 +45,7 @@
"default": {},
"description": "Applicable only when emmet.useNewEmmet is set to true.\nEnable emmet abbreviations in languages that are not supported by default. Add a mapping here between the language and emmet supported language.\n Eg: {\"vue-html\": \"html\", \"javascript\": \"javascriptreact\"}"
},
"emmet.variables":{
"emmet.variables": {
"type": "object",
"properties": {
"lang": {
@ -55,18 +57,125 @@
"default": "UTF-8"
}
},
"default":{},
"default": {},
"description": "Applicable only when emmet.useNewEmmet is set to true.\nVariables to be used in emmet snippets"
}
}
}
},
"commands": [
{
"command": "editor.emmet.action.removeTag",
"title": "%command.removeTag%",
"category": "Emmet"
},
{
"command": "editor.emmet.action.updateTag",
"title": "%command.updateTag%",
"category": "Emmet"
},
{
"command": "editor.emmet.action.matchTag",
"title": "%command.matchTag%",
"category": "Emmet"
},
{
"command": "editor.emmet.action.balanceIn",
"title": "%command.balanceIn%",
"category": "Emmet"
},
{
"command": "editor.emmet.action.balanceOut",
"title": "%command.balanceOut%",
"category": "Emmet"
},
{
"command": "editor.emmet.action.prevEditPoint",
"title": "%command.prevEditPoint%",
"category": "Emmet"
},
{
"command": "editor.emmet.action.nextEditPoint",
"title": "%command.nextEditPoint%",
"category": "Emmet"
},
{
"command": "editor.emmet.action.mergeLines",
"title": "%command.mergeLines%",
"category": "Emmet"
},
{
"command": "editor.emmet.action.selectPrevItem",
"title": "%command.selectPrevItem%",
"category": "Emmet"
},
{
"command": "editor.emmet.action.selectNextItem",
"title": "%command.selectNextItem%",
"category": "Emmet"
},
{
"command": "editor.emmet.action.splitJoinTag",
"title": "%command.splitJoinTag%",
"category": "Emmet"
},
{
"command": "editor.emmet.action.toggleComment",
"title": "%command.toggleComment%",
"category": "Emmet"
},
{
"command": "editor.emmet.action.evaluateMathExpression",
"title": "%command.evaluateMathExpression%",
"category": "Emmet"
},
{
"command": "editor.emmet.action.updateImageSize",
"title": "%command.updateImageSize%",
"category": "Emmet"
},
{
"command": "editor.emmet.action.incrementNumberByOneTenth",
"title": "%command.incrementNumberByOneTenth%",
"category": "Emmet"
},
{
"command": "editor.emmet.action.incrementNumberByOne",
"title": "%command.incrementNumberByOne%",
"category": "Emmet"
},
{
"command": "editor.emmet.action.incrementNumberByTen",
"title": "%command.incrementNumberByTen%",
"category": "Emmet"
},
{
"command": "editor.emmet.action.decrementNumberByOneTenth",
"title": "%command.decrementNumberByOneTenth%",
"category": "Emmet"
},
{
"command": "editor.emmet.action.decrementNumberByOne",
"title": "%command.decrementNumberByOne%",
"category": "Emmet"
},
{
"command": "editor.emmet.action.decrementNumberByTen",
"title": "%command.decrementNumberByTen%",
"category": "Emmet"
},
{
"command": "editor.emmet.action.reflectCSSValue",
"title": "%command.reflectCSSValue%",
"category": "Emmet"
}
]
},
"scripts": {
"compile": "gulp compile-extension:emmet"
},
"devDependencies": {
"@types/node": "^7.0.4",
"vscode": "1.0.1"
"vscode": "1.0.1"
},
"dependencies": {
"@emmetio/expand-abbreviation": "^0.5.8",
@ -74,8 +183,9 @@
"@emmetio/html-matcher": "^0.3.1",
"@emmetio/css-parser": "^0.3.0",
"@emmetio/math-expression": "^0.1.1",
"vscode-emmet-helper":"^1.0.0",
"vscode-emmet-helper": "^1.0.0",
"vscode-languageserver-types": "^3.0.3",
"image-size": "^0.5.2"
"image-size": "^0.5.2",
"vscode-nls": "2.0.2"
}
}

View file

@ -0,0 +1,23 @@
{
"command.removeTag": "Remove Tag",
"command.updateTag": "Update Tag",
"command.matchTag": "Go to Matching Pair",
"command.balanceIn": "Balance (inward)",
"command.balanceOut": "Balance (outward)",
"command.prevEditPoint": "Go to Previous Edit Point",
"command.nextEditPoint": "Go to Next Edit Point",
"command.mergeLines": "Merge Lines",
"command.selectPrevItem": "Select Previous Item",
"command.selectNextItem": "Select Next Item",
"command.splitJoinTag": "Split/Join Tag",
"command.toggleComment": "Toggle Comment",
"command.evaluateMathExpression": "Evaluate Math Expression",
"command.updateImageSize": "Update Image Size",
"command.reflectCSSValue": "Reflect CSS Value",
"command.incrementNumberByOne": "Increment by 1",
"command.decrementNumberByOne": "Decrement by 1",
"command.incrementNumberByOneTenth": "Increment by 0.1",
"command.decrementNumberByOneTenth": "Decrement by 0.1",
"command.incrementNumberByTen": "Increment by 10",
"command.decrementNumberByTen": "Decrement by 10"
}

View file

@ -35,11 +35,11 @@ export function activate(context: vscode.ExtensionContext) {
expandAbbreviation(args);
}));
context.subscriptions.push(vscode.commands.registerCommand('emmet.removeTag', () => {
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.removeTag', () => {
return removeTag();
}));
context.subscriptions.push(vscode.commands.registerCommand('emmet.updateTag', (inputTag) => {
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.updateTag', (inputTag) => {
if (inputTag && typeof inputTag === 'string') {
return updateTag(inputTag);
}
@ -48,79 +48,79 @@ export function activate(context: vscode.ExtensionContext) {
});
}));
context.subscriptions.push(vscode.commands.registerCommand('emmet.matchTag', () => {
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.matchTag', () => {
matchTag();
}));
context.subscriptions.push(vscode.commands.registerCommand('emmet.balanceOut', () => {
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.balanceOut', () => {
balanceOut();
}));
context.subscriptions.push(vscode.commands.registerCommand('emmet.balanceIn', () => {
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.balanceIn', () => {
balanceIn();
}));
context.subscriptions.push(vscode.commands.registerCommand('emmet.splitJoinTag', () => {
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.splitJoinTag', () => {
return splitJoinTag();
}));
context.subscriptions.push(vscode.commands.registerCommand('emmet.mergeLines', () => {
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.mergeLines', () => {
mergeLines();
}));
context.subscriptions.push(vscode.commands.registerCommand('emmet.toggleComment', () => {
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.toggleComment', () => {
toggleComment();
}));
context.subscriptions.push(vscode.commands.registerCommand('emmet.nextEditPoint', () => {
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.nextEditPoint', () => {
fetchEditPoint('next');
}));
context.subscriptions.push(vscode.commands.registerCommand('emmet.prevEditPoint', () => {
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.prevEditPoint', () => {
fetchEditPoint('prev');
}));
context.subscriptions.push(vscode.commands.registerCommand('emmet.selectNextItem', () => {
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.selectNextItem', () => {
fetchSelectItem('next');
}));
context.subscriptions.push(vscode.commands.registerCommand('emmet.selectPrevItem', () => {
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.selectPrevItem', () => {
fetchSelectItem('prev');
}));
context.subscriptions.push(vscode.commands.registerCommand('emmet.evaluateMathExpression', () => {
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.evaluateMathExpression', () => {
evaluateMathExpression();
}));
context.subscriptions.push(vscode.commands.registerCommand('emmet.incrementNumberByOneTenth', () => {
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.incrementNumberByOneTenth', () => {
return incrementDecrement(.1);
}));
context.subscriptions.push(vscode.commands.registerCommand('emmet.incrementNumberByOne', () => {
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.incrementNumberByOne', () => {
return incrementDecrement(1);
}));
context.subscriptions.push(vscode.commands.registerCommand('emmet.incrementNumberByTen', () => {
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.incrementNumberByTen', () => {
return incrementDecrement(10);
}));
context.subscriptions.push(vscode.commands.registerCommand('emmet.decrementNumberByOneTenth', () => {
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.decrementNumberByOneTenth', () => {
return incrementDecrement(-0.1);
}));
context.subscriptions.push(vscode.commands.registerCommand('emmet.decrementNumberByOne', () => {
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.decrementNumberByOne', () => {
return incrementDecrement(-1);
}));
context.subscriptions.push(vscode.commands.registerCommand('emmet.decrementNumberByTen', () => {
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.decrementNumberByTen', () => {
return incrementDecrement(-10);
}));
context.subscriptions.push(vscode.commands.registerCommand('emmet.updateImageSize', () => {
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.updateImageSize', () => {
return updateImageSize();
}));
context.subscriptions.push(vscode.commands.registerCommand('emmet.reflectCSSValue', () => {
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.reflectCSSValue', () => {
return reflectCssValue();
}));

View file

@ -9,7 +9,7 @@ import { Property, Rule } from 'EmmetNode';
const vendorPrefixes = ['-webkit-', '-moz-', '-ms-', '-o-', ''];
export function reflectCssValue() {
export function reflectCssValue(): Thenable<boolean> {
let editor = window.activeTextEditor;
if (!editor) {
window.showInformationMessage('No editor is active.');
@ -24,7 +24,7 @@ export function reflectCssValue() {
return updateCSSNode(editor, node);
}
function updateCSSNode(editor: TextEditor, property: Property) {
function updateCSSNode(editor: TextEditor, property: Property): Thenable<boolean> {
const rule: Rule = property.parent;
let currentPrefix = '';

View file

@ -4,8 +4,9 @@
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { Selection, commands } from 'vscode';
import { Selection } from 'vscode';
import { withRandomFileEditor, closeAllEditors } from './testUtils';
import { incrementDecrement } from '../incrementDecrement';
suite('Tests for Increment/Decrement Emmet Commands', () => {
teardown(closeAllEditors);
@ -19,7 +20,7 @@ suite('Tests for Increment/Decrement Emmet Commands', () => {
test('incrementNumberByOne', function (): any {
return withRandomFileEditor(contents, 'txt', (editor, doc) => {
editor.selections = [new Selection(1, 7, 1, 10), new Selection(2, 7, 2, 10)];
return commands.executeCommand('emmet.incrementNumberByOne').then(() => {
return incrementDecrement(1).then(() => {
assert.equal(doc.getText(), contents.replace('123', '124').replace('999', '1000'));
return Promise.resolve();
});
@ -29,7 +30,7 @@ suite('Tests for Increment/Decrement Emmet Commands', () => {
test('incrementNumberByTen', function (): any {
return withRandomFileEditor(contents, 'txt', (editor, doc) => {
editor.selections = [new Selection(1, 7, 1, 10), new Selection(2, 7, 2, 10)];
return commands.executeCommand('emmet.incrementNumberByTen').then(() => {
return incrementDecrement(10).then(() => {
assert.equal(doc.getText(), contents.replace('123', '133').replace('999', '1009'));
return Promise.resolve();
});
@ -39,7 +40,7 @@ suite('Tests for Increment/Decrement Emmet Commands', () => {
test('incrementNumberByOneTenth', function (): any {
return withRandomFileEditor(contents, 'txt', (editor, doc) => {
editor.selections = [new Selection(1, 7, 1, 13), new Selection(2, 7, 2, 12)];
return commands.executeCommand('emmet.incrementNumberByOneTenth').then(() => {
return incrementDecrement(0.1).then(() => {
assert.equal(doc.getText(), contents.replace('123.43', '123.53').replace('999.9', '1000'));
return Promise.resolve();
});
@ -49,7 +50,7 @@ suite('Tests for Increment/Decrement Emmet Commands', () => {
test('decrementNumberByOne', function (): any {
return withRandomFileEditor(contents, 'txt', (editor, doc) => {
editor.selections = [new Selection(1, 7, 1, 10), new Selection(3, 7, 3, 10)];
return commands.executeCommand('emmet.decrementNumberByOne').then(() => {
return incrementDecrement(-1).then(() => {
assert.equal(doc.getText(), contents.replace('123', '122').replace('100', '99'));
return Promise.resolve();
});
@ -59,7 +60,7 @@ suite('Tests for Increment/Decrement Emmet Commands', () => {
test('decrementNumberByTen', function (): any {
return withRandomFileEditor(contents, 'txt', (editor, doc) => {
editor.selections = [new Selection(1, 7, 1, 10), new Selection(3, 7, 3, 10)];
return commands.executeCommand('emmet.decrementNumberByTen').then(() => {
return incrementDecrement(-10).then(() => {
assert.equal(doc.getText(), contents.replace('123', '113').replace('100', '90'));
return Promise.resolve();
});
@ -69,7 +70,7 @@ suite('Tests for Increment/Decrement Emmet Commands', () => {
test('decrementNumberByOneTenth', function (): any {
return withRandomFileEditor(contents, 'txt', (editor, doc) => {
editor.selections = [new Selection(1, 7, 1, 13), new Selection(3, 7, 3, 10)];
return commands.executeCommand('emmet.decrementNumberByOneTenth').then(() => {
return incrementDecrement(-0.1).then(() => {
assert.equal(doc.getText(), contents.replace('123.43', '123.33').replace('100', '99.9'));
return Promise.resolve();
});

View file

@ -6,6 +6,7 @@
import * as assert from 'assert';
import { Selection, commands } from 'vscode';
import { withRandomFileEditor, closeAllEditors } from './testUtils';
import { reflectCssValue } from '../reflectCssValue';
suite('Tests for Emmet: Reflect CSS Value command', () => {
teardown(closeAllEditors);
@ -41,7 +42,7 @@ suite('Tests for Emmet: Reflect CSS Value command', () => {
test('Reflect Css Value in css file', function (): any {
return withRandomFileEditor(cssContents, '.css', (editor, doc) => {
editor.selections = [new Selection(5, 10, 5, 10)];
return commands.executeCommand('emmet.reflectCSSValue').then(() => {
return reflectCssValue().then(() => {
assert.equal(doc.getText(), cssContents.replace(/\(50deg\)/g, '(20deg)'));
return Promise.resolve();
});
@ -51,7 +52,7 @@ suite('Tests for Emmet: Reflect CSS Value command', () => {
test('Reflect Css Value in html file', function (): any {
return withRandomFileEditor(htmlContents, '.html', (editor, doc) => {
editor.selections = [new Selection(7, 20, 7, 20)];
return commands.executeCommand('emmet.reflectCSSValue').then(() => {
return reflectCssValue().then(() => {
assert.equal(doc.getText(), htmlContents.replace(/\(50deg\)/g, '(20deg)'));
return Promise.resolve();
});

View file

@ -4,8 +4,12 @@
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { Selection, commands } from 'vscode';
import { Selection } from 'vscode';
import { withRandomFileEditor, closeAllEditors } from './testUtils';
import { removeTag } from '../removeTag';
import { updateTag } from '../updateTag';
import { matchTag } from '../matchTag';
import { splitJoinTag } from '../splitJoinTag';
suite('Tests for Emmet actions on html tags', () => {
teardown(closeAllEditors);
@ -39,7 +43,7 @@ suite('Tests for Emmet actions on html tags', () => {
new Selection(5, 35, 5, 35), // cursor inside closing tag
];
return commands.executeCommand('emmet.updateTag', 'section').then(() => {
return updateTag('section').then(() => {
assert.equal(doc.getText(), expectedContents);
return Promise.resolve();
});
@ -65,7 +69,7 @@ suite('Tests for Emmet actions on html tags', () => {
new Selection(5, 35, 5, 35), // cursor inside closing tag
];
return commands.executeCommand('emmet.removeTag').then(() => {
return removeTag().then(() => {
assert.equal(doc.getText(), expectedContents);
return Promise.resolve();
});
@ -89,7 +93,7 @@ suite('Tests for Emmet actions on html tags', () => {
new Selection(7, 5, 7, 5), // split tag
];
return commands.executeCommand('emmet.splitJoinTag').then(() => {
return splitJoinTag().then(() => {
assert.equal(doc.getText(), expectedContents);
return Promise.resolve();
});
@ -107,17 +111,17 @@ suite('Tests for Emmet actions on html tags', () => {
new Selection(1, 19, 1, 19), // just after opening tag ends
];
return commands.executeCommand('emmet.matchTag').then(() => {
editor.selections.forEach(selection => {
assert.equal(selection.active.line, 8);
assert.equal(selection.active.character, 3);
assert.equal(selection.anchor.line, 8);
assert.equal(selection.anchor.character, 3);
});
matchTag();
return Promise.resolve();
editor.selections.forEach(selection => {
assert.equal(selection.active.line, 8);
assert.equal(selection.active.character, 3);
assert.equal(selection.anchor.line, 8);
assert.equal(selection.anchor.character, 3);
});
return Promise.resolve();
});
});
});
});

View file

@ -4,8 +4,9 @@
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { Selection, commands } from 'vscode';
import { Selection } from 'vscode';
import { withRandomFileEditor, closeAllEditors } from './testUtils';
import { updateImageSize } from '../updateImageSize';
import * as path from 'path';
suite('Tests for Emmet actions on html tags', () => {
@ -54,7 +55,7 @@ suite('Tests for Emmet actions on html tags', () => {
new Selection(11, 50, 11, 50)
];
return commands.executeCommand('emmet.updateImageSize').then(() => {
return updateImageSize().then(() => {
assert.equal(doc.getText(), expectedContents);
return Promise.resolve();
});
@ -111,7 +112,7 @@ suite('Tests for Emmet actions on html tags', () => {
new Selection(13, 50, 13, 50)
];
return commands.executeCommand('emmet.updateImageSize').then(() => {
return updateImageSize().then(() => {
assert.equal(doc.getText(), expectedContents);
return Promise.resolve();
});
@ -140,7 +141,7 @@ suite('Tests for Emmet actions on html tags', () => {
new Selection(4, 50, 4, 50)
];
return commands.executeCommand('emmet.updateImageSize').then(() => {
return updateImageSize().then(() => {
assert.equal(doc.getText(), expectedContents);
return Promise.resolve();
});

View file

@ -11,21 +11,8 @@ import { Registry } from 'vs/platform/registry/common/platform';
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
import './actions/expandAbbreviation';
import './actions/balance';
import './actions/matchingPair';
import './actions/wrapWithAbbreviation';
import './actions/editPoints';
import './actions/selectItem';
import './actions/toggleComment';
import './actions/splitJoinTag';
import './actions/removeTag';
import './actions/mergeLines';
import './actions/updateImageSize';
import './actions/evaluateMath';
import './actions/incrementDecrement';
import './actions/reflectCssValue';
// import './actions/base64'; // disabled - we will revisit the implementation
import './actions/updateTag';
// Configuration: emmet
const configurationRegistry = <IConfigurationRegistry>Registry.as(ConfigurationExtensions.Configuration);

View file

@ -237,29 +237,8 @@ export interface IEmmetActionOptions extends IActionOptions {
export abstract class EmmetEditorAction extends EditorAction {
private actionMap = {
'editor.emmet.action.removeTag': 'emmet.removeTag',
'editor.emmet.action.updateTag': 'emmet.updateTag',
'editor.emmet.action.matchingPair': 'emmet.matchTag',
'editor.emmet.action.wrapWithAbbreviation': 'emmet.wrapWithAbbreviation',
'editor.emmet.action.expandAbbreviation': 'emmet.expandAbbreviation',
'editor.emmet.action.balanceInward': 'emmet.balanceIn',
'editor.emmet.action.balanceOutward': 'emmet.balanceOut',
'editor.emmet.action.previousEditPoint': 'emmet.prevEditPoint',
'editor.emmet.action.nextEditPoint': 'emmet.nextEditPoint',
'editor.emmet.action.mergeLines': 'emmet.mergeLines',
'editor.emmet.action.selectPreviousItem': 'emmet.selectPrevItem',
'editor.emmet.action.selectNextItem': 'emmet.selectNextItem',
'editor.emmet.action.splitJoinTag': 'emmet.splitJoinTag',
'editor.emmet.action.toggleComment': 'emmet.toggleComment',
'editor.emmet.action.evaluateMath': 'emmet.evaluateMathExpression',
'editor.emmet.action.incrementNumberByOneTenth': 'emmet.incrementNumberByOneTenth',
'editor.emmet.action.incrementNumberByOne': 'emmet.incrementNumberByOne',
'editor.emmet.action.incrementNumberByTen': 'emmet.incrementNumberByTen',
'editor.emmet.action.decrementNumberByOneTenth': 'emmet.decrementNumberByOneTenth',
'editor.emmet.action.decrementNumberByOne': 'emmet.decrementNumberByOne',
'editor.emmet.action.decrementNumberByTen': 'emmet.decrementNumberByTen',
'editor.emmet.action.updateImageSize': 'emmet.updateImageSize',
'editor.emmet.action.reflectCSSValue': 'emmet.reflectCSSValue'
'editor.emmet.action.expandAbbreviation': 'emmet.expandAbbreviation'
};
protected emmetActionName: string;