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
Invalid emmet abbr returns weird expanded value in css files #27628
*duplicateIssue identified as a duplicate of another issue(s)emmetEmmet related issuesupstreamIssue identified as 'upstream' component related (exists outside of VS Code)
changed the title [-]Using emmet expand abbreviation in a sass file gives weird output[/-][+]Invalid emmet abbr returns weird expanded value in css files[/+]on May 30, 2017
Sergey Chikuyonok (@sergeche) Would you expect the plugin to parse the css file and call expand-abbreviation only if the cursor is in the "rule" part of the css file? Or is there any validation from the emmet modules that we can make use of?
Since auto-complete will get triggered for every new letter typed, either the emmet plugin should be smart enough not to try to expand .foo in the context of css or the css parser being used should not treat it as an abbreviation
Ramya Rao (@ramya-rao-a) you can re-use @emmetio/html-matcher and @emmetio/css-parser to quickly parse a document. These parsers are pretty fast: on my MacBook Pro they are able to parse a 500 KB document in about 10 ms. But it’s a good idea to implement a VSCode-specific StreamReader as in Atom plugin. The goal of this reader is to use text coordinates native to editor and use editor’s content representation model. For example, Atom stores text content as lines of text so instead of spending resources on allocating memory for a whole text content and then translate text coordinates into editor ones, I simply read directly from editor in it’s coordiantes
Sergey Chikuyonok (@sergeche) I implemented a stream reader for VS Code's TextDocument, and am currently parsing the document to avoid suggesting emmet expansions in invalid locations like inside the open tag in html or a selector in css.
But take the case of scss where you can have nested selectors. In this case, when we start typing a nested selector, the parser is not aware of whether the user is typing another property or a new selector. In this case, we end up with the below both in Atom and VS Code
So even though editors try and figure out the right scope for emmet abbreviations, I believe the extract-abbreviation module can use some validation of its own based on simple regex.
*duplicateIssue identified as a duplicate of another issue(s)emmetEmmet related issuesupstreamIssue identified as 'upstream' component related (exists outside of VS Code)
Activity
ramya-rao-a commentedon May 30, 2017
haha
.foois not a valid abbreviation to expand, and the extension should handle it better.[-]Using emmet expand abbreviation in a sass file gives weird output[/-][+]Invalid emmet abbr returns weird expanded value in css files[/+]ramya-rao-a commentedon Jun 5, 2017
Sergey Chikuyonok (@sergeche) Would you expect the plugin to parse the css file and call
expand-abbreviationonly if the cursor is in the "rule" part of the css file? Or is there any validation from the emmet modules that we can make use of?jens1o commentedon Jun 5, 2017
Sorry to interrupt but this is valid?
.class=><div class="class">|</div>(such as
#header=><div id="header"></div>)https://docs.emmet.io/cheat-sheet/
ramya-rao-a commentedon Jun 5, 2017
Jens Hausdorf (@jens1o) It is valid html, so yes it is valid
jens1o commentedon Jun 5, 2017
Then I'm sorry, but I do not understand what you're trying to say.
ramya-rao-a commentedon Jun 5, 2017
Oh I mean when taken in the context of css
.foois not a valid abbreviationIn the context of html it certainly is.
In this issue we are talking about css abbreviation
jens1o commentedon Jun 5, 2017
Ah, sorry, then I didn't get the subject.
ramya-rao-a commentedon Jun 5, 2017
Since auto-complete will get triggered for every new letter typed, either the emmet plugin should be smart enough not to try to expand
.fooin the context of css or the css parser being used should not treat it as an abbreviation4 remaining items
ramya-rao-a commentedon Jun 7, 2017
Sergey Chikuyonok (@sergeche) Ah the catch there is that scope info is not available to VS Code extensions :( See #580
And so I will either end up parsing the whole file to see if cursor is in a selector/rule or try to do some regex magic.
sergeche commentedon Jun 7, 2017
Ramya Rao (@ramya-rao-a) you can re-use
@emmetio/html-matcherand@emmetio/css-parserto quickly parse a document. These parsers are pretty fast: on my MacBook Pro they are able to parse a 500 KB document in about 10 ms. But it’s a good idea to implement a VSCode-specificStreamReaderas in Atom plugin. The goal of this reader is to use text coordinates native to editor and use editor’s content representation model. For example, Atom stores text content as lines of text so instead of spending resources on allocating memory for a whole text content and then translate text coordinates into editor ones, I simply read directly from editor in it’s coordiantesFred-Vatin commentedon Jun 13, 2017
In the new emmet, would this issue solve the current one when something like
c:ris expanded ascolor: r;instead ofcolor: rgb(0, 0, 0);?sergeche commentedon Jun 13, 2017
Can be solved by providing more value samples for
csnippet: https://github.com/emmetio/snippets/blob/master/css.json#L76ramya-rao-a commentedon Jun 19, 2017
Sergey Chikuyonok (@sergeche) I implemented a stream reader for VS Code's TextDocument, and am currently parsing the document to avoid suggesting emmet expansions in invalid locations like inside the open tag in html or a selector in css.
But take the case of scss where you can have nested selectors. In this case, when we start typing a nested selector, the parser is not aware of whether the user is typing another property or a new selector. In this case, we end up with the below both in Atom and VS Code
So even though editors try and figure out the right scope for emmet abbreviations, I believe the
extract-abbreviationmodule can use some validation of its own based on simple regex.sergeche commentedon Jun 19, 2017
Yes, stubled with this issue too, will fix CSS abbreviation parser
ramya-rao-a commentedon Jun 19, 2017
Sergey Chikuyonok (@sergeche) Can we do the same for html as well? That would solve #27975
sergeche commentedon Jun 19, 2017
Yes. Please create a separate issue at https://github.com/emmetio/atom-plugin/issues so I can better track bugs
ramya-rao-a commentedon Jun 19, 2017
Thanks Sergey Chikuyonok (@sergeche) !
Logged emmetio/atom-plugin#22
ramya-rao-a commentedon Jun 22, 2017
Closing this in favor of #27975