Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css] Show multiple elements suggestions #249

Open
m0ksem opened this issue Sep 17, 2021 · 10 comments
Open

[css] Show multiple elements suggestions #249

m0ksem opened this issue Sep 17, 2021 · 10 comments
Assignees
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities
Milestone

Comments

@m0ksem
Copy link

m0ksem commented Sep 17, 2021

input {
  &:hover, &:focus {
    &::placeholder {
      color: red;
    } 
  }
}

image

For example show it as:

<input :hover ::placeholder> or <input :focus ::placeholder>

or

<input :hover ::placeholder>
<input :focus ::placeholder>

Codepen: https://codepen.io/m0ksem/pen/qBjxxzo

@aeschli aeschli added feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities labels Oct 7, 2021
@aeschli aeschli added this to the Backlog milestone Oct 7, 2021
@aeschli aeschli self-assigned this Oct 7, 2021
@GauravB159
Copy link
Contributor

@aeschli Could I look into this issue? I'm a bit familiar with the CSS Language service after working on a couple PRs.

Also, if this is implemented, would the selector specificity necessarily be the same for multiple element suggestions? One might have a different specificity than the other, how would we handle that?

@aeschli
Copy link
Contributor

aeschli commented Nov 8, 2022

@GauravB159 Of course, that would be reat. I think each variant would need its own specificity.

Code is in https://github.com/microsoft/vscode-css-languageservice/blob/main/src/services/cssHover.ts

The hover. Content is an array and can contain any number of parts. Maybe that helps.

@aeschli aeschli changed the title Show multiple elements suggestions [css] Show multiple elements suggestions Nov 8, 2022
@GauravB159
Copy link
Contributor

Awesome, I'll look into it, thank you! @aeschli For the specificity, would displaying them in the same order as the list of elements be enough context to understand which specificity maps to which element?

@aeschli
Copy link
Contributor

aeschli commented Nov 8, 2022

@GauravB159 For you to experiment. Maybe it can look like that:

<input :hover ::placeholder>
Selector specificity: (0.0.1)
<input :focus ::placeholder>
Selector specificity: (0.0.1)

If they are the same, maybe one line (at the bottom) is enough.

@GauravB159
Copy link
Contributor

@aeschli Gotcha, I'll try it out, thank you.

@GauravB159
Copy link
Contributor

@aeschli I'm testing out the changes for this and I noticed MarkedString is supposed to be deprecated. Does that need to be replaced with something else?

image

@GauravB159
Copy link
Contributor

@aeschli Here's what I've got so far:

The multiple suggestions seem to be working fine. The specificity probably has some bugs. Can you confirm what the values should be?

Because I've cross checked them with the prod build of VSCode and they're the same but shouldn't ID and Class have different specificity values?


My changes for multiple suggestions:

image

Prod version with single suggestion:

image

@m0ksem
Copy link
Author

m0ksem commented Nov 8, 2022

Hi @GauravB159, thanks for dealing with this issue. This looks cool already.

ID should have 1.0.0 specificity according to MDN.

:hover should add 0.1.0 to specificity. It looks like parent selector specificity doesn't count here.
So, input.class:hover should have 0.2.1 specificity, but it shows 0.1.0 because this popover is related to :hover selector only.
Same with input#id:hover should be 1.1.1. But, :hover alone is 0.1.0 which is correct.

Here's a calculator to self check. Looks like it calculates all correct.

@GauravB159
Copy link
Contributor

GauravB159 commented Nov 8, 2022

Hi @m0ksem, no worries! I'm new to open source, but really having fun contributing.

So for the specificity, I figured the values were wrong. But, there seems to be a bug in prod itself that causes the calculation to be wrong, if you check the screenshot. I'm not sure if I should address that bug in this issue, or create a separate issue for that.

Also, if you check my PR, I have added a case that has not been handled in my fix. Do you think that case should be handled, or the way it is currently coded is fine?

Edit: The issue seems to be in SCSS files only when nesting is used, CSS files work fine for specificity since there is no nesting. Can you try it out and let me know if you're facing the same issue?

input { #id { p { color: red; } } } - Returns (0, 0, 1)

input #id p { color: red; } - Returns (1, 0, 2)

@aeschli
Copy link
Contributor

aeschli commented Nov 8, 2022

Yes, let's deal with the specificity issue in a different issue. Thanks @m0ksem for bringing this to attention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities
Projects
None yet
Development

No branches or pull requests

3 participants