pranaygp / vscode-css-peek

A vscode extension for peeking at CSS definitions from a class or id tag in HTML
MIT License
145 stars 32 forks source link

Improve performance by using a Language Server Protocol #1

Closed KillyMXI closed 6 years ago

KillyMXI commented 7 years ago

Other than being slow in some cases, current behaviour can also result in showing minified css files instead of original sources.

The common way to solve this issue is to introduce include and exclude settings in a form of glob patterns.

pranaygp commented 7 years ago

@KillyMXI, this is good idea and also simple fix and I can get to it eventually. However, would you like to make a PR? Might get done sooner that way :)

pranaygp commented 7 years ago

In version 1.3.0, we now have a configuration option for excluding files/folders by regex expressions (instead of globs as you suggested)

KillyMXI commented 7 years ago

Figured out the way to exclude everything except the single folder I need. But with the probability of about 20% it still shows the content from file that should have been excluded. Tried to exclude single unwanted folder - got the same result.

No performance improvements, too (not much styles left to process - I don't see the reason for it to be that slow).

pranaygp commented 7 years ago

I need to try and repro. I've only been testing this on a small project and it worked as expected. I should probably be testing on larger projects especially for performance.

If your project is on GitHub, could you give me a link to it so I can test it out with that?

KillyMXI commented 7 years ago

It's not public, unfortunately.

pranaygp commented 7 years ago

No worries. I'll try and find a project I can repro this on. Now that VScode let's me setup a language service (or maybe it always did and I didn't know about it). I can hopefully significantly improve performance and kick of a V2 of this. :D

pranaygp commented 6 years ago

Version 2.0 is out, and it makes use of the language server protocol. Most importantly, I find, parse and cache all the file ASTs from the workspace as soon as the extension is activated. Also, when files are modified, the extension updates the cache accordingly and reparses the file (this could be CPU intensive, but it's asynchronous and runs in a different process from VSCode so it shouldn't affect VSCode).

When you lookup definition (Cmd + E, or Cmd + click, etc.) I simply use the cached stylesheets to make this much much faster.