pucelle / vscode-css-navigation

Allowing Go to definition from HTML to CSS, or Find References from CSS to HTML.
https://marketplace.visualstudio.com/items?itemName=pucelle.vscode-css-navigation
MIT License
64 stars 8 forks source link

Request textDocument/completion failed with message: Cannot read property 'length' of null #56

Closed kanlukasz closed 3 years ago

kanlukasz commented 3 years ago

Issue description:

The plugin returns a warning and an error when i start to work with my project. At first glance, this only happens once when I start working with code.

The Output from CSS Navigation looks like this:

[18:25:37] Client for workspace folder "public_html" started
[18:25:37] Server for workspace folder "public_html" started
[Warn  - 6:38:09 PM] [18:38:09] Timer "track" is not started
[Error - 6:38:09 PM] Request textDocument/completion failed.
  Message: Request textDocument/completion failed with message: Cannot read property 'length' of null
  Code: -32603 

Plugin settings:

"CSSNavigation.activeCSSFileExtensions": [
    "css",
    "scss"
],
"CSSNavigation.activeHTMLFileExtensions": [
    "html",
    "php"
],
"CSSNavigation.alwaysIncludeGlobPatterns": [
    "**/node_modules/bootstrap/dist/css/bootstrap.css"
],
"CSSNavigation.excludeGlobPatterns": [
    "**/wp-content/themes/project/assets/css/**",
    "**/node_modules/**",
    "**/bower_components/**",
    "**/vendor/**",
    "**/coverage/**"
],

My environment:

pucelle commented 3 years ago

Hi, kanlukasz , can you provide some code examples which will raise the error?

kanlukasz commented 3 years ago

I tested it with this code:

<div class="col-12 col-md-4 my-3 my-md-0">
    <div class="d-flex justify-content-center align-items-center h-100 bg-light rounded p-2">
        <span class="font-weight-bold text-danger">INFOLINE</span>
    </div>
</div>

It is difficult to create a step-by-step description of the problem because it doesn't happen every time.

I tested it again and found it happens when I don't wait a moment after starting or reloading VSCode and start typing a css class right away

Looks like something is not loading at the very beginning?

image

pucelle commented 3 years ago

Thanks, I will look at it later.

Cronkan commented 3 years ago

In my case it was because of a *.min.css file. Fixed it by adding this:

  "CSSNavigation.alwaysIncludeGlobPatterns": ["**/node_modules/bootstrap/dist/css/!(*min.css)"],
  "CSSNavigation.excludeGlobPatterns": [
    "**/node_modules/**",
    "**/bower_components/**",
    "**/vendor/**",
    "**/coverage/**",
    "**/*.min.css"
  ]
pucelle commented 3 years ago

I've checked in some codes, but it only come from my guessing, I can't ensure it can fix this issue, this issue is really too hard to reproduce.

pucelle commented 3 years ago

Temporary closed, never mind to reopen it.