You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Emmet css abbreviation not expanded in style block in html file #28039
changed the title [-]Emmet only provides html snippets, not css ones[/-][+]Emmet css abbreviation not expanded in style block in html file[/+]on Jun 5, 2017
I initially thought that the completion provider for css from emmet does not get called here because the document has the html language mode. And so logged #28047
But interestingly, the built-in css completion provider does get called.
If the css extension/language server does something special to be able to provide completion items in html file, what do you suggest other extensions who want to do the same do?
How is that in the above case the built-in css completion provider is called but not the emmet css completion provider?
It always depends on the language you are registering for. I'd say that inside style-tags we use css as language and therefore only call completion item providers that have registered for css
Funky.. If I press d I see completions coming from emmet, also checking what completion provider buckets we have it seems that there are two registered fro CSS.
Also, when I invoke suggestions inside an empty rule (remove d) I see this
Cannot set property 'kind' of undefined: TypeError: Cannot set property 'kind' of undefined
at EmmetCompletionItemProviderHtml.getExpandedAbbreviation (/Users/jrieken/Code/vscode/extensions/emmet/out/emmetCompletionProvider.js:52:29)
at EmmetCompletionItemProviderHtml.provideCompletionItems (/Users/jrieken/Code/vscode/extensions/emmet/out/emmetCompletionProvider.js:18:33)
at /Users/jrieken/Code/vscode/out/vs/workbench/api/node/extHostLanguageFeatures.js:385:85
at /Users/jrieken/Code/vscode/out/vs/base/common/async.js:33:24
at new Promise_ctor (/Users/jrieken/Code/vscode/out/vs/base/common/winjs.base.raw.js:1641:17)
at Object.asWinJsPromise (/Users/jrieken/Code/vscode/out/vs/base/common/async.js:32:16)
at SuggestAdapter.provideCompletionItems (/Users/jrieken/Code/vscode/out/vs/workbench/api/node/extHostLanguageFeatures.js:385:28)
at /Users/jrieken/Code/vscode/out/vs/workbench/api/node/extHostLanguageFeatures.js:732:98
at ExtHostLanguageFeatures._withAdapter (/Users/jrieken/Code/vscode/out/vs/workbench/api/node/extHostLanguageFeatures.js:573:20)
at ExtHostLanguageFeatures.$provideCompletionItems (/Users/jrieken/Code/vscode/out/vs/workbench/api/node/extHostLanguageFeatures.js:732:25)
Yes, that is from emmet. If you expand the docs you will see the preview for the expansion.
In your case above, the completion item is coming from the html completion provider in emmet i.e for d you get <d>/</d> where as the css completion provider would have given display:block
also checking what completion provider buckets we have it seems that there are two registered fro CSS.
The first one must be coming from the html extension.
The second one is the html completion provider from emmet. ( I can tell the difference from the trigger chars. For css they would have been just :.)
This one should have been the css completion provider from emmet.
Also, when I invoke suggestions inside an empty rule (remove d) I see this
I dont see that in Insiders but I see that in the locally built VS Code. Weird.. how is that? We dont surface errors from extensions in a non dev env?
Ok, now I know what's up. Martin Aeschlimann (@aeschli) Will have all the detail but I remember correctly nested languages aren't surfaced like that. While we have a scope source.css inside the html-file we actually treat all contents as html and call into html-providers which then must do the correct thing.
Ramya Rao (@ramya-rao-a) You only changed the Completion Provider, but not the actions (at least expandAbbreviation action)?
And another problem: You implementation will provide emmet in the start tag of a style element, because you set the syntax to css for this tag.
<style|>
I'm working on a tool for my team with monaco-editor and trying to backport the new emmet vscode extension to monaco (Now the Completion Provider and expandAbbreviation action just work). I had never used emmet before neither, but now I think the implementation will be very complex: you need to handle normal HTML, in style attribute (doesn't need selectors) and in style element (need selectors) very differently.
@CnSimonChan I had another task in mind to consolidate the code between the completion provider and the action which I was planning to do today which would cover your concern.
And good catch on the style tag, will add the check on the tag as well. Will re-open this issue until this is fixed. Thanks for reporting!
@CnSimonChan With 8902a30 you now have the same validations being run and syntax being used by the completion provider and the expand abbreviation action.
css inside style element
no expansions inside the open tag for style element
You bring up another good point about the style attribute. Logged #29066 for the same.
Yes, things are getting complex in this model where a lot of work has moved from emmet to editor.
I am not sure what it takes for the new emmet functionality to be ported to monaco editor, but I can look into it and get back to you.
Ramya Rao (@ramya-rao-a) It works very well now, maybe another improvement will be re-parse the content of <style> tag as css to provide emmet only for rules.
For monaco, I wrote a minimal compatibility layer to bridge monaco's IStandaloneCodeEditor and IModel to vscode's TextEditor and TextDocument , then bridge vscode's CompletionItemProvider to monaco one. I'm not familiar with vscode and I can't find any relative code in the repo so maybe I'm doing something redundant.
I have two more question with this extension:
My npm@5 crashed when restoring packages for this extension, it seems the npm-shrinkwarp.json file caused the crash, I deleted this file then it restores correctly.
Do you have definition files for emmet packages somewhere? I found one in src folder but looks like it's for the old all-in-one version. Or you just work with any?
I have noImplicitAny on so I wrote some definition by myself, just covered the need of the extension (although I'm not very clear about the return type of html-matcher and css-parser). It's better if someone good at creating type definition can help, but if not I will post it tomorrow (after 10 hours) and hope it can be useful.
Activity
jens1o commentedon Jun 5, 2017
I created this issue, because it is not mentioned here: #27697
Did you missed it?
ramya-rao-a commentedon Jun 5, 2017
This works in css/scss/less files, but not inside the
styleblock of a html file.Good catch.
[-]Emmet only provides html snippets, not css ones[/-][+]Emmet css abbreviation not expanded in style block in html file[/+]ramya-rao-a commentedon Jun 5, 2017
I initially thought that the completion provider for css from emmet does not get called here because the document has the html language mode. And so logged #28047
But interestingly, the built-in css completion provider does get called.
Martin Aeschlimann (@aeschli) Johannes Rieken (@jrieken) How is that in the above case the built-in css completion provider is called but not the emmet css completion provider?
If the css extension/language server does something special to be able to provide completion items in html file, what do you suggest other extensions who want to do the same do?
jrieken commentedon Jun 6, 2017
It always depends on the language you are registering for. I'd say that inside
style-tags we usecssas language and therefore only call completion item providers that have registered forcssramya-rao-a commentedon Jun 7, 2017
Johannes Rieken (@jrieken) See https://github.com/Microsoft/vscode/blob/ramyar/emmet-fixes/extensions/emmet/src/extension.ts#L54
I have 2 separate completion providers for html vs css
While inside
styletag, the one for html gets called and not the css.should we specify anything else in the DocumentSelector for VS code to use the registered completion provider for embedded languages?
jrieken commentedon Jun 8, 2017
Hm, that looks correct... Would require some debugging in
suggest.tswhere we merge the results etc. Is this locally reproducible with those steps?ramya-rao-a commentedon Jun 8, 2017
Johannes Rieken (@jrieken) Yes. The changes are in master, so you can try this locally.
jrieken commentedon Jun 8, 2017
Funky.. If I press
dI see completions coming from emmet, also checking what completion provider buckets we have it seems that there are two registered fro CSS.Also, when I invoke suggestions inside an empty rule (remove
d) I see thisramya-rao-a commentedon Jun 8, 2017
Yes, that is from emmet. If you expand the docs you will see the preview for the expansion.
In your case above, the completion item is coming from the html completion provider in emmet i.e for
dyou get<d>/</d>where as the css completion provider would have givendisplay:blockThe first one must be coming from the html extension.
The second one is the html completion provider from emmet. ( I can tell the difference from the trigger chars. For css they would have been just
:.)This one should have been the css completion provider from emmet.
I dont see that in Insiders but I see that in the locally built VS Code. Weird.. how is that? We dont surface errors from extensions in a non dev env?
jrieken commentedon Jun 8, 2017
Ok, now I know what's up. Martin Aeschlimann (@aeschli) Will have all the detail but I remember correctly nested languages aren't surfaced like that. While we have a scope
source.cssinside the html-file we actually treat all contents as html and call into html-providers which then must do the correct thing.9 remaining items
ramya-rao-a commentedon Jun 19, 2017
The fix will be out in the Tuesday's Insiders
yume-chan commentedon Jun 19, 2017
Ramya Rao (@ramya-rao-a) You only changed the Completion Provider, but not the actions (at least expandAbbreviation action)?
And another problem: You implementation will provide emmet in the start tag of a
styleelement, because you set thesyntaxtocssfor this tag.I'm working on a tool for my team with monaco-editor and trying to backport the new emmet vscode extension to monaco (Now the Completion Provider and expandAbbreviation action just work). I had never used emmet before neither, but now I think the implementation will be very complex: you need to handle normal HTML, in
styleattribute (doesn't need selectors) and instyleelement (need selectors) very differently.sergeche commentedon Jun 19, 2017
Ramya Rao (@ramya-rao-a) you have to check if cursor is not inside
.openor.closetag token to fix the problem that @CnSimonChan pointed. See https://github.com/emmetio/atom-plugin/blob/master/lib/actions/balance.js#L84 as example of getting inner node rangeramya-rao-a commentedon Jun 19, 2017
@CnSimonChan I had another task in mind to consolidate the code between the completion provider and the action which I was planning to do today which would cover your concern.
And good catch on the
styletag, will add the check on the tag as well. Will re-open this issue until this is fixed. Thanks for reporting!Sergey Chikuyonok (@sergeche) For now I am using https://github.com/Microsoft/vscode/blob/master/extensions/emmet/src/emmetCompletionProvider.ts#L134 for validating the position. I'll take another look at the atom implementation to ensure I have not missed any other cases.
ramya-rao-a commentedon Jun 20, 2017
@CnSimonChan With 8902a30 you now have the same validations being run and syntax being used by the completion provider and the expand abbreviation action.
You bring up another good point about the style attribute. Logged #29066 for the same.
Yes, things are getting complex in this model where a lot of work has moved from emmet to editor.
I am not sure what it takes for the new emmet functionality to be ported to monaco editor, but I can look into it and get back to you.
yume-chan commentedon Jun 20, 2017
Ramya Rao (@ramya-rao-a) It works very well now, maybe another improvement will be re-parse the content of
<style>tag as css to provide emmet only for rules.For monaco, I wrote a minimal compatibility layer to bridge monaco's
IStandaloneCodeEditorandIModelto vscode'sTextEditorandTextDocument, then bridge vscode'sCompletionItemProviderto monaco one. I'm not familiar with vscode and I can't find any relative code in the repo so maybe I'm doing something redundant.I have two more question with this extension:
My
npm@5crashed when restoring packages for this extension, it seems thenpm-shrinkwarp.jsonfile caused the crash, I deleted this file then it restores correctly.Do you have definition files for emmet packages somewhere? I found one in
srcfolder but looks like it's for the old all-in-one version. Or you just work withany?ramya-rao-a commentedon Jun 20, 2017
I gave this a thought, but will not be doing this for the current iteration. Logged #29113 and added a help-wanted label on it.
Not sure about this. The shrink-wrap is used during shipping time, so not needed during the development phase. Did you try with a lower npm version?
Ahhh... This is something I have been needing as well. Sergey Chikuyonok (@sergeche) Could you help here ?
yume-chan commentedon Jun 20, 2017
No, I have only 5.
I have
noImplicitAnyon so I wrote some definition by myself, just covered the need of the extension (although I'm not very clear about the return type ofhtml-matcherandcss-parser). It's better if someone good at creating type definition can help, but if not I will post it tomorrow (after 10 hours) and hope it can be useful.ramya-rao-a commentedon Jun 26, 2017
Note to verifier:
emmet.useNewEmmettotrueUse css abbreviations inside html style block. Fixes microsoft#28039