Skip to content

Invalid emmet abbr returns weird expanded value in css files #27628

Closed

Description

@Tyriar
  • VSCode Version: Code - Insiders 1.13.0-insider (c2a17a7, 2017-05-30T05:12:15.312Z)
  • OS Version: Linux x64 4.10.0-21-generic
  • Extensions:
Extension Author Version
EditorConfig EditorConfig 0.9.3
lorem-ipsum Tyriar 1.0.0
sort-lines Tyriar 1.3.0
theme-sapphire Tyriar 0.2.1
vscode-svgviewer cssho 1.4.1
tslint eg2 0.15.0
git-project-manager felipecaputo 1.3.2
md-navigate jrieken 0.0.1
vscode-scss mrmlnc 0.6.2
seti-icons qinjia 0.1.3

#27316

image

image

Activity

  1. added
    emmet
    on May 30, 2017
  2. ramya-rao-a commented on May 30, 2017

    @ramya-rao-a
    Contributor

    haha .foo is not a valid abbreviation to expand, and the extension should handle it better.

  3. 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
  4. added
    bug
    on May 30, 2017
  5. ramya-rao-a commented on Jun 5, 2017

    @ramya-rao-a
    Contributor

    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?

  6. jens1o commented on Jun 5, 2017

    @jens1o
    Contributor

    Sorry to interrupt but this is valid? .class => <div class="class">|</div>

    image

    (such as #header => <div id="header"></div>)

    https://docs.emmet.io/cheat-sheet/

  7. ramya-rao-a commented on Jun 5, 2017

    @ramya-rao-a
    Contributor

    Jens Hausdorf (@jens1o) It is valid html, so yes it is valid

  8. jens1o commented on Jun 5, 2017

    @jens1o
    Contributor

    Then I'm sorry, but I do not understand what you're trying to say.

    haha .foo is not a valid abbreviation to expand, and the extension should handle it better.

  9. ramya-rao-a commented on Jun 5, 2017

    @ramya-rao-a
    Contributor

    Oh I mean when taken in the context of css .foo is not a valid abbreviation
    In the context of html it certainly is.

    In this issue we are talking about css abbreviation

  10. jens1o commented on Jun 5, 2017

    @jens1o
    Contributor

    Ah, sorry, then I didn't get the subject.

  11. ramya-rao-a commented on Jun 5, 2017

    @ramya-rao-a
    Contributor

    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

  12. 4 remaining items

  13. ramya-rao-a commented on Jun 7, 2017

    @ramya-rao-a
    Contributor

    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.

  14. sergeche commented on Jun 7, 2017

    @sergeche

    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

  15. Fred-Vatin commented on Jun 13, 2017

    @Fred-Vatin

    In the new emmet, would this issue solve the current one when something like c:r is expanded as color: r; instead of color: rgb(0, 0, 0); ?

  16. ramya-rao-a commented on Jun 19, 2017

    @ramya-rao-a
    Contributor

    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

    screen shot 2017-06-18 at 11 29 35 pm

    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.

  17. sergeche commented on Jun 19, 2017

    @sergeche

    Yes, stubled with this issue too, will fix CSS abbreviation parser

  18. ramya-rao-a commented on Jun 19, 2017

    @ramya-rao-a
    Contributor

    Sergey Chikuyonok (@sergeche) Can we do the same for html as well? That would solve #27975

  19. sergeche commented on Jun 19, 2017

    @sergeche
  20. ramya-rao-a commented on Jun 19, 2017

    @ramya-rao-a
    Contributor
  21. added
    upstream
    on Jun 19, 2017
  22. ramya-rao-a commented on Jun 22, 2017

    @ramya-rao-a
    Contributor

    Closing this in favor of #27975

  23. added
    *duplicate
    and removed
    bug
    on Jun 29, 2017
  24. locked and limited conversation to collaborators on Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

*duplicateemmetupstream

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions