microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.49k stars 28.65k forks source link

Support for choices in Emmet snippets #33994

Closed ramya-rao-a closed 6 years ago

ramya-rao-a commented 7 years ago

We now have support for choices in snippets via #17545

But these choices don't show up in Emmet snippets. For example the transform snippet as defined here: https://github.com/emmetio/snippets/blob/v0.2.5/css.json#L178

ramya-rao-a commented 6 years ago

The syntax for choices in snippets as supported by VS Code and as used by Emmet (https://github.com/emmetio/snippets/blob/v0.2.5/css.json#L178) are very different.

Plus, the main selling point of Emmet abbreviations is the brevity and the ability to get the snippets with the least amount of clicks.

The main issue that was the reason of creating this current issue was that snippets like trf:x would not get expanded as expected.

I reasoned that will snippet choices, we can surface this. But now I don't think that snippet choices is the right solution here.

On digging deeper, I found the root cause for trf:x not expanding as expected to be that the logic that finds best match in Emmet 2.0 is case sensitive.

So trf:X would expand as expected, but trf:x wouldn't

I have logged an upstream issue for this: https://github.com/emmetio/css-snippets-resolver/issues/6

ramya-rao-a commented 6 years ago

Pushed a fix to ignore case when fuzzy matching,

Sotrf:rx will now rightly expand to transform: rotateX(angle)

Note to verifiers:

From the css section in the emmet cheatsheet try out any of the abbreviations which have :

ramya-rao-a commented 6 years ago

cc @LukeMcGurdy

roblourens commented 6 years ago

In bds:n the n doesn't expand to none like the cheatsheet says it should. Probably not a vscode issue though.

roblourens commented 6 years ago

image

Do you know where the first n suggestion comes from? Annoying to have to go past that for emmet. This is with --disable-extensions

ramya-rao-a commented 6 years ago

@roblourens On bds:n, what a catch. This is because none is not present in the bds snippet!!! See https://github.com/emmetio/snippets/blob/master/css.json#L49 Submited PR for the same: https://github.com/emmetio/snippets/pull/5

The first n that you see is coming from the css completion provider. I have no clue what that is though. @aeschli might know

aeschli commented 6 years ago

I don't know where the 'n' comes from. Do you have another property called 'te' that already has value 'n'? I'd need a code sample to investigate more.

ramya-rao-a commented 6 years ago

@aeschli The "n" appears even without any other property in the file

Try

.foo {
    te:n
}

image

ramya-rao-a commented 6 years ago

@aeschli The n is being added from here: https://github.com/Microsoft/vscode-css-languageservice/blob/master/src/services/cssCompletion.ts#L214

It just echos what is already present

image

aeschli commented 6 years ago

@ramya-rao-a Thanks for finding the problem. Fix is on the way...

ramya-rao-a commented 6 years ago

Verified the fix, thanks @aeschli!