microsoft / vscode

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

HTML path quick suggestion do not trigger when typing a letter #46145

Closed mjbvz closed 6 years ago

mjbvz commented 6 years ago

Steps to Reproduce:

  1. In a project:

    index.html
    src/
    a.js
  2. With index.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script src="./"></script>
</body>
</html>
  1. In the script src, type s to create './s'

Bug No quick suggestions

mjbvz commented 6 years ago

This has the same root cause as #46142. The attribute value is considered a string so normal quick suggestions are disabled.

You can override the token type using the new tokenTypes grammar contribution: 95a406bd2ae73065e1f4277b6a909792aa38e87d

octref commented 6 years ago

Somehow I cannot load css languages after splitting the folders. Once @aeschli help me out on this I can test adding the tokenTypes for css too and close the issue.

mjbvz commented 6 years ago

You may want to scope 581000a to just tags where quick suggestions should be active (namely those for paths). Not sure if treating all tag values as other instead of string will cause any problems

octref commented 6 years ago

@mjbvz Thanks for fixing it. I did it for css, but couldn't for less and scss.

@mjbvz For less

image

This does not work, still marked as String.

"tokenTypes": {
  "support.function.any-method string.quoted": "other"
}

This marks it as Other.

"tokenTypes": {
  "support.function string.quoted": "other"
}

I thought the dash was causing the problem, but I saw you are having entity.name.function.tagged-template.js.jsx. Any thoughts?

@aeschli SCSS grammar does not have a token type for URL function. Should I just forget about SCSS?

image

aeschli commented 6 years ago

@octref I think the better fix is to add that to the package.json:

    "configurationDefaults": {
      "[html]": {
        "editor.quickSuggestions": {
          "strings": true
        }
      }
    }

Same for css. It's not that URL are not strings. They are. It's that we also have good proposals inside strings.

mjbvz commented 6 years ago

@aeschli That would enable quick suggestions in all strings, which could be annoying since word based suggestions and snippet suggestions will now show up. The intent of tokenTypes is to allow us to treat specific strings as language features instead of as normal string strings

aeschli commented 6 years ago

Look how string literals are used in HTML and CSS. They all represent values. In these values, quick suggestions should work. I'm not a fan of word based suggestions and snippet suggestions either, but there's no reason that these do not show up in such values.

octref commented 6 years ago

I found these suggestions very noisy:

image

I'm not a fan of word based suggestions and snippet suggestions either, but there's no reason that these do not show up in such values.

We can leave that to the user to config. The current fix limits its scope to only string literals.