microsoft / vscode-css-languageservice

CSS, LESS & SCSS language service extracted from VSCode to be reused, e.g in the Monaco editor.
MIT License
317 stars 176 forks source link

Added multiple element preview on hover of scss selector #308

Open GauravB159 opened 1 year ago

GauravB159 commented 1 year ago

Partial fix for #249

Still need to figure out the logic for specificity. There seems to be some kind of bug in the production build itself.

Still need to add tests for the new feature.

GauravB159 commented 1 year ago

image

Such cases have not been handled yet, only the case where an element's immediate parents are multiple has been handled. I'm not sure if we want to handle this case, since it might just get too complicated. If needed, I can possibly extend it to cover this as well using a recursive method.

aeschli commented 1 year ago

Yes, I agree that this can get very complicated. The hover size should not get too long. Maybe write (1 more) behind <element class="div-two"> ?

GauravB159 commented 1 year ago

Hmm, I'm not sure how to limit the depth. Possibly depends on what the most frequent use case for this would be. I don't think people would want to preview a really deep node list anyways.

I'm not sure what you mean by write one more behind <element class="div-two">?

Basically, the way it currently works is, if the second to last nested selector has multiple values, it picks up those, but other than that it picks the first selector in each ancestor.

Basically a depth of 1, I guess.