Repository navigation
Support for Emmet preferences and syntaxProfiles - #7926
Erich Gamma (egamma) merged 2 commits into
Conversation
|
Hi Denis Malinochkin (@mrmlnc), I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! TTYL, MSBOT; |
|
Denis Malinochkin (@mrmlnc) Thanks for the well documented Pull Request. I've looked into the emmet preferences API and I don't fully understand your explanation of why you did not use If |
|
Now I see, set throws an exception, when the setting is not defined... Object.keys(prefs).forEach(function(k) {
var v = prefs[k];
if (!(k in defaults)) {
throw new Error('Property "' + k + '" is not defined. You should define it first with `define` method of current module');
} |
|
OK, I now catch the exception when the preferences isn't defined yet and then I define the setting. I also use the approach to merge in the editor settings before an emmet operation and then I reset them after. This simplifies the implementation. Please review. |
|
Erich Gamma (@egamma), unfortunately, we are both wrong. My versionMethod Your versionMore likely, most users will not use the Emmet preferences and syntaxProfiles. Thus, the setting and resetting of settings when each action is not the best idea (deoptimization?). For example: My proposalUse the methods P.S.: Sorry for my English. |
I made some small changes so that there is no overhead when the user doesn't have emmet preferences. I must say I like the simplicity of the current code compared to the original PR. However, if the simple code is not correct, then it needs to be fixed 😄. I'll also implement a solution that uses your approach and then we can compare. OK? |
|
Erich Gamma (@egamma), good idea.
The thing is that i originally thought to allow users to change all settings. But looking at the code of Emmet i realized that they are meaningless. My vision settings for Emmet: mrmlnc/vscode/../emmetActions.ts |
|
Denis Malinochkin (@mrmlnc) please tell me how to execute a command "wrap abbreviation" on hotkey? |
[{
"key": "ctrl+alt+w",
"command": "editor.emmet.action.wrapWithAbbreviation",
"when": "editorTextFocus"
}] |
DisclaimerI don't know how much is a correct test, but the results are interesting. Tests
ResultsCurrent version (first run ~300ms)Current version witn Emmet bundle by Gulp (first run ~300ms)My version (code) (first run ~150ms)My version with Emmet bundle by Gulp (first run ~150ms) |
|
Erich Gamma (@egamma) i just moved And settings apply when they are changed. |
The EmmetAction constructor is called during startup. This means your version activates emmet on startup, which is what we want to avoid we do not want to add to the startup time. This is why we load emmet on the first tab key.
Keep in mind that the Action constructor is called for each action, this means you register a listener for each action (which I think there are now 17). This also means you update the preferences multiple times.
|
|
Erich Gamma (@egamma), you are right. |
|
Denis Malinochkin (@mrmlnc) thanks for the investigation anyways, it shows that the bundling of emmet is not a win. |





Excuse
Sorry, but this is my first experience with the TypeScript. If everything is very bad, then let me know about this or add the proposed PR manually with correct code.
Why?
In the previous PR was added support Emmet for Sass and Stylus (#7887). That's cool, but Stylus has free syntax. For example:
By default, Emmet has the syntax:
position absoluteorfont-size 14px. Using the Emmet preferences you can fix this. This PR adds support for Emmet preferences and syntaxProfiles.Demo
Emmet preferences:
Emmet syntaxProfiles
Why you do not use
emmet.preferences.load()oremmet.loadPreferences()Unfortunately, both methods work only with
emmet.preferences.set()and not provide access toemmet.preferences.define()that there is a need for rules that are not declared by default.Question for developers
I'm not sure that the code in the constructor is correct. I couldn't think of a better way for access to Emmet one time.