Revert "Fix #58600, Format Emmet package.json (#110891)"

This reverts commit ffacef4727.
This commit is contained in:
Raymond Zhao
2020-11-23 09:02:15 -08:00
parent 40a902c9cf
commit 4c55c7264f
7 changed files with 544 additions and 517 deletions

View File

@@ -1,461 +1,446 @@
{
"name": "emmet",
"displayName": "Emmet",
"description": "%description%",
"version": "1.0.0",
"publisher": "vscode",
"license": "MIT",
"engines": {
"vscode": "^1.13.0"
},
"icon": "images/icon.png",
"categories": [
"Other"
],
"repository": {
"type": "git",
"url": "https://github.com/microsoft/vscode-emmet"
},
"activationEvents": [
"*",
"onCommand:emmet.expandAbbreviation",
"onLanguage:html",
"onLanguage:css",
"onLanguage:scss",
"onLanguage:less"
],
"main": "./out/node/emmetNodeMain",
"browser": "./dist/browser/emmetBrowserMain",
"contributes": {
"configuration": {
"type": "object",
"title": "Emmet",
"properties": {
"emmet.showExpandedAbbreviation": {
"type": [
"string"
],
"enum": [
"never",
"always",
"inMarkupAndStylesheetFilesOnly"
],
"default": "always",
"markdownDescription": "%emmetShowExpandedAbbreviation%"
},
"emmet.showAbbreviationSuggestions": {
"type": "boolean",
"default": true,
"markdownDescription": "%emmetShowAbbreviationSuggestions%"
},
"emmet.includeLanguages": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"default": {},
"markdownDescription": "%emmetIncludeLanguages%"
},
"emmet.variables": {
"type": "object",
"properties": {
"lang": {
"type": "string",
"default": "en"
},
"charset": {
"type": "string",
"default": "UTF-8"
}
},
"default": {},
"description": "%emmetVariables%"
},
"emmet.syntaxProfiles": {
"type": "object",
"default": {},
"description": "%emmetSyntaxProfiles%"
},
"emmet.excludeLanguages": {
"type": "array",
"default": [
"markdown"
],
"description": "%emmetExclude%"
},
"emmet.extensionsPath": {
"type": [
"string",
"null"
],
"default": null,
"description": "%emmetExtensionsPath%"
},
"emmet.triggerExpansionOnTab": {
"type": "boolean",
"default": false,
"description": "%emmetTriggerExpansionOnTab%"
},
"emmet.preferences": {
"type": "object",
"default": {},
"description": "%emmetPreferences%",
"properties": {
"css.intUnit": {
"type": "string",
"default": "px",
"description": "%emmetPreferencesIntUnit%"
},
"css.floatUnit": {
"type": "string",
"default": "em",
"description": "%emmetPreferencesFloatUnit%"
},
"css.propertyEnd": {
"type": "string",
"default": ";",
"description": "%emmetPreferencesCssAfter%"
},
"sass.propertyEnd": {
"type": "string",
"default": "",
"description": "%emmetPreferencesSassAfter%"
},
"stylus.propertyEnd": {
"type": "string",
"default": "",
"description": "%emmetPreferencesStylusAfter%"
},
"css.valueSeparator": {
"type": "string",
"default": ": ",
"description": "%emmetPreferencesCssBetween%"
},
"sass.valueSeparator": {
"type": "string",
"default": ": ",
"description": "%emmetPreferencesSassBetween%"
},
"stylus.valueSeparator": {
"type": "string",
"default": " ",
"description": "%emmetPreferencesStylusBetween%"
},
"bem.elementSeparator": {
"type": "string",
"default": "__",
"description": "%emmetPreferencesBemElementSeparator%"
},
"bem.modifierSeparator": {
"type": "string",
"default": "_",
"description": "%emmetPreferencesBemModifierSeparator%"
},
"filter.commentBefore": {
"type": "string",
"default": "",
"description": "%emmetPreferencesFilterCommentBefore%"
},
"filter.commentAfter": {
"type": "string",
"default": "\n<!-- /[#ID][.CLASS] -->",
"description": "%emmetPreferencesFilterCommentAfter%"
},
"filter.commentTrigger": {
"type": "array",
"default": [
"id",
"class"
],
"description": "%emmetPreferencesFilterCommentTrigger%"
},
"format.noIndentTags": {
"type": "array",
"default": [
"html"
],
"description": "%emmetPreferencesFormatNoIndentTags%"
},
"format.forceIndentationForTags": {
"type": "array",
"default": [
"body"
],
"description": "%emmetPreferencesFormatForceIndentTags%"
},
"profile.allowCompactBoolean": {
"type": "boolean",
"default": false,
"description": "%emmetPreferencesAllowCompactBoolean%"
},
"css.webkitProperties": {
"type": "string",
"default": null,
"markdownDescription": "%emmetPreferencesCssWebkitProperties%"
},
"css.mozProperties": {
"type": "string",
"default": null,
"markdownDescription": "%emmetPreferencesCssMozProperties%"
},
"css.oProperties": {
"type": "string",
"default": null,
"markdownDescription": "%emmetPreferencesCssOProperties%"
},
"css.msProperties": {
"type": "string",
"default": null,
"markdownDescription": "%emmetPreferencesCssMsProperties%"
},
"css.fuzzySearchMinScore": {
"type": "number",
"default": 0.3,
"description": "%emmetPreferencesCssFuzzySearchMinScore%"
}
}
},
"emmet.showSuggestionsAsSnippets": {
"type": "boolean",
"default": false,
"markdownDescription": "%emmetShowSuggestionsAsSnippets%"
},
"emmet.optimizeStylesheetParsing": {
"type": "boolean",
"default": true,
"markdownDescription": "%emmetOptimizeStylesheetParsing%"
}
}
"name": "emmet",
"displayName": "Emmet",
"description": "%description%",
"version": "1.0.0",
"publisher": "vscode",
"license": "MIT",
"engines": {
"vscode": "^1.13.0"
},
"commands": [
{
"command": "editor.emmet.action.wrapIndividualLinesWithAbbreviation",
"title": "%command.wrapIndividualLinesWithAbbreviation%",
"category": "Emmet"
},
{
"command": "editor.emmet.action.wrapWithAbbreviation",
"title": "%command.wrapWithAbbreviation%",
"category": "Emmet"
},
{
"command": "editor.emmet.action.expandAbbreviation",
"title": "%command.expandAbbreviation%",
"category": "Emmet"
},
{
"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"
},
{
"command": "workbench.action.showEmmetCommands",
"title": "%command.showEmmetCommands%",
"category": ""
}
"icon": "images/icon.png",
"categories": [
"Other"
],
"keybindings": [
{
"key": "tab",
"command": "editor.emmet.action.expandAbbreviation",
"when": "config.emmet.triggerExpansionOnTab && editorTextFocus && !editorReadonly && !editorTabMovesFocus"
}
"repository": {
"type": "git",
"url": "https://github.com/microsoft/vscode-emmet"
},
"activationEvents": [
"*",
"onCommand:emmet.expandAbbreviation",
"onLanguage:html",
"onLanguage:css",
"onLanguage:scss",
"onLanguage:less"
],
"menus": {
"commandPalette": [
{
"command": "editor.emmet.action.wrapIndividualLinesWithAbbreviation"
"main": "./out/node/emmetNodeMain",
"browser": "./dist/browser/emmetBrowserMain",
"contributes": {
"configuration": {
"type": "object",
"title": "Emmet",
"properties": {
"emmet.showExpandedAbbreviation": {
"type": [
"string"
],
"enum": [
"never",
"always",
"inMarkupAndStylesheetFilesOnly"
],
"default": "always",
"markdownDescription": "%emmetShowExpandedAbbreviation%"
},
"emmet.showAbbreviationSuggestions": {
"type": "boolean",
"default": true,
"markdownDescription": "%emmetShowAbbreviationSuggestions%"
},
"emmet.includeLanguages": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"default": {},
"markdownDescription": "%emmetIncludeLanguages%"
},
"emmet.variables": {
"type": "object",
"properties": {
"lang": {
"type": "string",
"default": "en"
},
"charset": {
"type": "string",
"default": "UTF-8"
}
},
"default": {},
"description": "%emmetVariables%"
},
"emmet.syntaxProfiles": {
"type": "object",
"default": {},
"description": "%emmetSyntaxProfiles%"
},
"emmet.excludeLanguages": {
"type": "array",
"default": [
"markdown"
],
"description": "%emmetExclude%"
},
"emmet.extensionsPath": {
"type": [
"string",
"null"
],
"default": null,
"description": "%emmetExtensionsPath%"
},
"emmet.triggerExpansionOnTab": {
"type": "boolean",
"default": false,
"description": "%emmetTriggerExpansionOnTab%"
},
"emmet.preferences": {
"type": "object",
"default": {},
"description": "%emmetPreferences%",
"properties": {
"css.intUnit": {
"type": "string",
"default": "px",
"description": "%emmetPreferencesIntUnit%"
},
"css.floatUnit": {
"type": "string",
"default": "em",
"description": "%emmetPreferencesFloatUnit%"
},
"css.propertyEnd": {
"type": "string",
"default": ";",
"description": "%emmetPreferencesCssAfter%"
},
"sass.propertyEnd": {
"type": "string",
"default": "",
"description": "%emmetPreferencesSassAfter%"
},
"stylus.propertyEnd": {
"type": "string",
"default": "",
"description": "%emmetPreferencesStylusAfter%"
},
"css.valueSeparator": {
"type": "string",
"default": ": ",
"description": "%emmetPreferencesCssBetween%"
},
"sass.valueSeparator": {
"type": "string",
"default": ": ",
"description": "%emmetPreferencesSassBetween%"
},
"stylus.valueSeparator": {
"type": "string",
"default": " ",
"description": "%emmetPreferencesStylusBetween%"
},
"bem.elementSeparator": {
"type": "string",
"default": "__",
"description": "%emmetPreferencesBemElementSeparator%"
},
"bem.modifierSeparator": {
"type": "string",
"default": "_",
"description": "%emmetPreferencesBemModifierSeparator%"
},
"filter.commentBefore": {
"type": "string",
"default": "",
"description": "%emmetPreferencesFilterCommentBefore%"
},
"filter.commentAfter": {
"type": "string",
"default": "\n<!-- /[#ID][.CLASS] -->",
"description": "%emmetPreferencesFilterCommentAfter%"
},
"filter.commentTrigger": {
"type": "array",
"default": [
"id",
"class"
],
"description": "%emmetPreferencesFilterCommentTrigger%"
},
"format.noIndentTags": {
"type": "array",
"default": [
"html"
],
"description": "%emmetPreferencesFormatNoIndentTags%"
},
"format.forceIndentationForTags": {
"type": "array",
"default": [
"body"
],
"description": "%emmetPreferencesFormatForceIndentTags%"
},
"profile.allowCompactBoolean": {
"type": "boolean",
"default": false,
"description": "%emmetPreferencesAllowCompactBoolean%"
},
"css.webkitProperties": {
"type": "string",
"default": null,
"markdownDescription": "%emmetPreferencesCssWebkitProperties%"
},
"css.mozProperties": {
"type": "string",
"default": null,
"markdownDescription": "%emmetPreferencesCssMozProperties%"
},
"css.oProperties": {
"type": "string",
"default": null,
"markdownDescription": "%emmetPreferencesCssOProperties%"
},
"css.msProperties": {
"type": "string",
"default": null,
"markdownDescription": "%emmetPreferencesCssMsProperties%"
},
"css.fuzzySearchMinScore": {
"type": "number",
"default": 0.3,
"description": "%emmetPreferencesCssFuzzySearchMinScore%"
}
}
},
"emmet.showSuggestionsAsSnippets": {
"type": "boolean",
"default": false,
"markdownDescription": "%emmetShowSuggestionsAsSnippets%"
},
"emmet.optimizeStylesheetParsing": {
"type": "boolean",
"default": true,
"markdownDescription": "%emmetOptimizeStylesheetParsing%"
}
}
},
{
"command": "editor.emmet.action.wrapWithAbbreviation"
},
{
"command": "editor.emmet.action.expandAbbreviation"
},
{
"command": "editor.emmet.action.removeTag"
},
{
"command": "editor.emmet.action.updateTag"
},
{
"command": "editor.emmet.action.matchTag"
},
{
"command": "editor.emmet.action.balanceIn"
},
{
"command": "editor.emmet.action.balanceOut"
},
{
"command": "editor.emmet.action.prevEditPoint"
},
{
"command": "editor.emmet.action.nextEditPoint"
},
{
"command": "editor.emmet.action.mergeLines"
},
{
"command": "editor.emmet.action.selectPrevItem"
},
{
"command": "editor.emmet.action.selectNextItem"
},
{
"command": "editor.emmet.action.splitJoinTag"
},
{
"command": "editor.emmet.action.toggleComment"
},
{
"command": "editor.emmet.action.evaluateMathExpression"
},
{
"command": "editor.emmet.action.updateImageSize",
"when": "resourceScheme =~ /^file$/"
},
{
"command": "editor.emmet.action.incrementNumberByOneTenth"
},
{
"command": "editor.emmet.action.incrementNumberByOne"
},
{
"command": "editor.emmet.action.incrementNumberByTen"
},
{
"command": "editor.emmet.action.decrementNumberByOneTenth"
},
{
"command": "editor.emmet.action.decrementNumberByOne"
},
{
"command": "editor.emmet.action.decrementNumberByTen"
},
{
"command": "editor.emmet.action.reflectCSSValue"
"commands": [
{
"command": "editor.emmet.action.wrapIndividualLinesWithAbbreviation",
"title": "%command.wrapIndividualLinesWithAbbreviation%",
"category": "Emmet"
},
{
"command": "editor.emmet.action.wrapWithAbbreviation",
"title": "%command.wrapWithAbbreviation%",
"category": "Emmet"
},
{
"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"
},
{
"command": "workbench.action.showEmmetCommands",
"title": "%command.showEmmetCommands%",
"category": ""
}
],
"menus": {
"commandPalette": [
{
"command": "editor.emmet.action.wrapIndividualLinesWithAbbreviation"
},
{
"command": "editor.emmet.action.wrapWithAbbreviation"
},
{
"command": "editor.emmet.action.removeTag"
},
{
"command": "editor.emmet.action.updateTag"
},
{
"command": "editor.emmet.action.matchTag"
},
{
"command": "editor.emmet.action.balanceIn"
},
{
"command": "editor.emmet.action.balanceOut"
},
{
"command": "editor.emmet.action.prevEditPoint"
},
{
"command": "editor.emmet.action.nextEditPoint"
},
{
"command": "editor.emmet.action.mergeLines"
},
{
"command": "editor.emmet.action.selectPrevItem"
},
{
"command": "editor.emmet.action.selectNextItem"
},
{
"command": "editor.emmet.action.splitJoinTag"
},
{
"command": "editor.emmet.action.toggleComment"
},
{
"command": "editor.emmet.action.evaluateMathExpression"
},
{
"command": "editor.emmet.action.updateImageSize",
"when": "resourceScheme =~ /^file$/"
},
{
"command": "editor.emmet.action.incrementNumberByOneTenth"
},
{
"command": "editor.emmet.action.incrementNumberByOne"
},
{
"command": "editor.emmet.action.incrementNumberByTen"
},
{
"command": "editor.emmet.action.decrementNumberByOneTenth"
},
{
"command": "editor.emmet.action.decrementNumberByOne"
},
{
"command": "editor.emmet.action.decrementNumberByTen"
},
{
"command": "editor.emmet.action.reflectCSSValue"
}
]
}
]
},
"scripts": {
"watch": "gulp watch-extension:emmet",
"compile": "gulp compile-extension:emmet",
"deps": "yarn add vscode-emmet-helper"
},
"devDependencies": {
"@types/node": "^12.11.7",
"mocha-junit-reporter": "^1.17.0",
"mocha-multi-reporters": "^1.1.7",
"vscode": "1.0.1"
},
"dependencies": {
"@emmetio/css-parser": "ramya-rao-a/css-parser#vscode",
"@emmetio/html-matcher": "^0.3.3",
"@emmetio/math-expression": "^1.0.4",
"image-size": "^0.5.2",
"vscode-emmet-helper": "~2.0.0",
"vscode-html-languageservice": "^3.0.3"
}
},
"scripts": {
"watch": "gulp watch-extension:emmet",
"compile": "gulp compile-extension:emmet",
"deps": "yarn add vscode-emmet-helper"
},
"devDependencies": {
"@types/node": "^12.11.7",
"mocha-junit-reporter": "^1.17.0",
"mocha-multi-reporters": "^1.1.7",
"vscode": "1.0.1"
},
"dependencies": {
"@emmetio/css-parser": "ramya-rao-a/css-parser#vscode",
"@emmetio/html-matcher": "^0.3.3",
"@emmetio/math-expression": "^1.0.4",
"image-size": "^0.5.2",
"vscode-emmet-helper": "~2.0.0",
"vscode-html-languageservice": "^3.0.3"
}
}

View File

@@ -2,7 +2,6 @@
"description": "Emmet support for VS Code",
"command.wrapWithAbbreviation": "Wrap with Abbreviation",
"command.wrapIndividualLinesWithAbbreviation": "Wrap Individual Lines with Abbreviation",
"command.expandAbbreviation": "Expand Abbreviation",
"command.removeTag": "Remove Tag",
"command.updateTag": "Update Tag",
"command.matchTag": "Go to Matching Pair",

View File

@@ -31,14 +31,10 @@ export function activateEmmetExtension(context: vscode.ExtensionContext) {
wrapIndividualLinesWithAbbreviation(args);
}));
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.expandAbbreviationInternal', (args) => {
context.subscriptions.push(vscode.commands.registerCommand('emmet.expandAbbreviation', (args) => {
expandEmmetAbbreviation(args);
}));
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.expandAbbreviation', () => {
vscode.commands.executeCommand('workbench.action.expandEmmetAbbreviation');
}));
context.subscriptions.push(vscode.commands.registerCommand('editor.emmet.action.removeTag', () => {
return removeTag();
}));

View File

@@ -0,0 +1,43 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vs/nls';
import { EmmetEditorAction } from 'vs/workbench/contrib/emmet/browser/emmetActions';
import { registerEditorAction } from 'vs/editor/browser/editorExtensions';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { KeyCode } from 'vs/base/common/keyCodes';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { MenuId } from 'vs/platform/actions/common/actions';
class ExpandAbbreviationAction extends EmmetEditorAction {
constructor() {
super({
id: 'editor.emmet.action.expandAbbreviation',
label: nls.localize('expandAbbreviationAction', "Emmet: Expand Abbreviation"),
alias: 'Emmet: Expand Abbreviation',
precondition: EditorContextKeys.writable,
actionName: 'expand_abbreviation',
kbOpts: {
primary: KeyCode.Tab,
kbExpr: ContextKeyExpr.and(
EditorContextKeys.editorTextFocus,
EditorContextKeys.tabDoesNotMoveFocus,
ContextKeyExpr.has('config.emmet.triggerExpansionOnTab')
),
weight: KeybindingWeight.EditorContrib
},
menuOpts: {
menuId: MenuId.MenubarEditMenu,
group: '5_insert',
title: nls.localize({ key: 'miEmmetExpandAbbreviation', comment: ['&& denotes a mnemonic'] }, "Emmet: E&&xpand Abbreviation"),
order: 3
}
});
}
}
registerEditorAction(ExpandAbbreviationAction);

View File

@@ -3,7 +3,5 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { registerEditorCommand } from 'vs/editor/browser/editorExtensions';
import { expandEmmetAbbreviationCommand } from './expandEmmetAbbreviation';
import './actions/expandAbbreviation';
registerEditorCommand(expandEmmetAbbreviationCommand);

View File

@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ServicesAccessor, EditorCommand } from 'vs/editor/browser/editorExtensions';
import { EditorAction, ServicesAccessor, IActionOptions } from 'vs/editor/browser/editorExtensions';
import { grammarsExtPoint, ITMSyntaxExtensionPoint } from 'vs/workbench/services/textMate/common/TMGrammars';
import { IModeService } from 'vs/editor/common/services/modeService';
import { IExtensionService, ExtensionPointContribution } from 'vs/workbench/services/extensions/common/extensions';
@@ -24,6 +24,7 @@ export interface ILanguageIdentifierResolver {
}
class GrammarContributions implements IGrammarContributions {
private static _grammars: ModeScopeMap = {};
constructor(contributions: ExtensionPointContribution<ITMSyntaxExtensionPoint[]>[]) {
@@ -47,12 +48,20 @@ class GrammarContributions implements IGrammarContributions {
}
}
export class ExpandEmmetAbbreviationCommand extends EditorCommand {
constructor() {
super({ id: 'workbench.action.expandEmmetAbbreviation', precondition: undefined });
export interface IEmmetActionOptions extends IActionOptions {
actionName: string;
}
export abstract class EmmetEditorAction extends EditorAction {
protected emmetActionName: string;
constructor(opts: IEmmetActionOptions) {
super(opts);
this.emmetActionName = opts.actionName;
}
private static readonly emmetSupportedModes = ['html', 'xml', 'xsl', 'jsx', 'js', 'pug', 'slim', 'haml', 'css', 'sass', 'scss', 'less', 'sss', 'stylus'];
private static readonly emmetSupportedModes = ['html', 'css', 'xml', 'xsl', 'haml', 'jade', 'jsx', 'slim', 'scss', 'sass', 'less', 'stylus', 'styl', 'svg'];
private _lastGrammarContributions: Promise<GrammarContributions> | null = null;
private _lastExtensionService: IExtensionService | null = null;
@@ -66,21 +75,20 @@ export class ExpandEmmetAbbreviationCommand extends EditorCommand {
return this._lastGrammarContributions || Promise.resolve(null);
}
public runEditorCommand(accessor: ServicesAccessor | null, editor: ICodeEditor, args: any): void | Promise<void> {
if (!accessor) {
return;
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): Promise<void> {
const extensionService = accessor.get(IExtensionService);
const modeService = accessor.get(IModeService);
const commandService = accessor.get(ICommandService);
return this._withGrammarContributions(extensionService).then((grammarContributions) => {
if (this.id === 'workbench.action.expandEmmetAbbreviation' && grammarContributions) {
return commandService.executeCommand<void>('editor.emmet.action.expandAbbreviationInternal', ExpandEmmetAbbreviationCommand.getLanguage(modeService, editor, grammarContributions));
if (this.id === 'editor.emmet.action.expandAbbreviation' && grammarContributions) {
return commandService.executeCommand<void>('emmet.expandAbbreviation', EmmetEditorAction.getLanguage(modeService, editor, grammarContributions));
}
return undefined;
});
}
public static getLanguage(languageIdentifierResolver: ILanguageIdentifierResolver, editor: ICodeEditor, grammars: IGrammarContributions) {
@@ -96,34 +104,24 @@ export class ExpandEmmetAbbreviationCommand extends EditorCommand {
const languageId = model.getLanguageIdAtPosition(position.lineNumber, position.column);
const languageIdentifier = languageIdentifierResolver.getLanguageIdentifier(languageId);
const language = languageIdentifier ? languageIdentifier.language : '';
let syntax = language.split('.').pop();
const syntax = language.split('.').pop();
if (!syntax) {
return null;
}
// map to something Emmet understands
if (['jsx-tags', 'javascriptreact', 'typescriptreact'].includes(syntax)) {
syntax = 'jsx';
}
const getParentMode = (syntax: string): string => {
if (syntax === 'jsx') {
// return otherwise getGrammar gives a string that Emmet doesn't understand
return syntax;
}
const languageGrammar = grammars.getGrammar(syntax);
let checkParentMode = (): string => {
let languageGrammar = grammars.getGrammar(syntax);
if (!languageGrammar) {
return syntax;
}
const languages = languageGrammar.split('.');
if (languages.length <= 1) {
let languages = languageGrammar.split('.');
if (languages.length < 2) {
return syntax;
}
for (let i = languages.length - 1; i >= 1; i--) {
const language = languages[i];
if (this.emmetSupportedModes.includes(language)) {
for (let i = 1; i < languages.length; i++) {
const language = languages[languages.length - i];
if (this.emmetSupportedModes.indexOf(language) !== -1) {
return language;
}
}
@@ -132,9 +130,9 @@ export class ExpandEmmetAbbreviationCommand extends EditorCommand {
return {
language: syntax,
parentMode: getParentMode(syntax)
parentMode: checkParentMode()
};
}
}
export const expandEmmetAbbreviationCommand = new ExpandEmmetAbbreviationCommand();
}

View File

@@ -3,11 +3,29 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IGrammarContributions, ILanguageIdentifierResolver, ExpandEmmetAbbreviationCommand } from 'vs/workbench/contrib/emmet/browser/expandEmmetAbbreviation';
import { IGrammarContributions, ILanguageIdentifierResolver, EmmetEditorAction } from 'vs/workbench/contrib/emmet/browser/emmetActions';
import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
import * as assert from 'assert';
import { LanguageId, LanguageIdentifier } from 'vs/editor/common/modes';
//
// To run the emmet tests only change .vscode/launch.json
// {
// "name": "Stacks Tests",
// "type": "node",
// "request": "launch",
// "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
// "stopOnEntry": false,
// "args": [
// "--timeout",
// "999999",
// "--colors",
// "-g",
// "Stacks" <<<--- Emmet
// ],
// Select the 'Stacks Tests' launch config and F5
//
class MockGrammarContributions implements IGrammarContributions {
private scopeName: string;
@@ -15,14 +33,16 @@ class MockGrammarContributions implements IGrammarContributions {
this.scopeName = scopeName;
}
public getGrammar(_: string): string {
public getGrammar(mode: string): string {
return this.scopeName;
}
}
suite('Emmet expandAbbreviation command', () => {
test('gets language mode and parent mode for Emmet', () => {
suite('Emmet', () => {
test('Get language mode and parent mode for emmet', () => {
withTestCodeEditor([], {}, (editor) => {
function testIsEnabled(mode: string, scopeName: string, expectedLanguage?: string, expectedParentLanguage?: string) {
const languageIdentifier = new LanguageIdentifier(mode, 73);
const languageIdentifierResolver: ILanguageIdentifierResolver = {
@@ -39,13 +59,13 @@ suite('Emmet expandAbbreviation command', () => {
}
model.setMode(languageIdentifier);
const langOutput = ExpandEmmetAbbreviationCommand.getLanguage(languageIdentifierResolver, editor, new MockGrammarContributions(scopeName));
let langOutput = EmmetEditorAction.getLanguage(languageIdentifierResolver, editor, new MockGrammarContributions(scopeName));
if (!langOutput) {
assert.fail('langOutput not found');
}
assert.strictEqual(langOutput.language, expectedLanguage);
assert.strictEqual(langOutput.parentMode, expectedParentLanguage);
assert.equal(langOutput.language, expectedLanguage);
assert.equal(langOutput.parentMode, expectedParentLanguage);
}
// syntaxes mapped using the scope name of the grammar
@@ -54,22 +74,10 @@ suite('Emmet expandAbbreviation command', () => {
testIsEnabled('nunjucks', 'text.html.nunjucks', 'nunjucks', 'html');
testIsEnabled('laravel-blade', 'text.html.php.laravel-blade', 'laravel-blade', 'html');
// basic syntaxes
testIsEnabled('html', 'text.html.derivative', 'html', 'html');
testIsEnabled('css', 'source.css', 'css', 'css');
testIsEnabled('scss', 'source.css.scss', 'scss', 'scss');
testIsEnabled('xml', 'text.xml', 'xml', 'xml');
testIsEnabled('xsl', 'text.xml.xsl', 'xsl', 'xsl');
// languages that have different Language Id and scopeName
// testIsEnabled('razor', 'text.html.cshtml', 'razor', 'html');
// testIsEnabled('HTML (Eex)', 'text.html.elixir', 'boo', 'html');
// syntaxes that combine HTML and TS/JS
// expanding inside of HTML tags within jsx/tsx
testIsEnabled('jsx-tags', 'source.js.jsx', 'jsx', 'jsx');
// expanding outside of HTML tags within jsx/tsx
testIsEnabled('javascriptreact', 'source.js.jsx', 'jsx', 'jsx');
testIsEnabled('typescriptreact', 'source.tsx', 'jsx', 'jsx');
// syntaxes that combine HTML and some other language
testIsEnabled('razor', 'text.html.cshtml', 'razor', 'html');
});
});
});