Skip to content

Glob patterns #100

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

Merged
merged 4 commits into from
Nov 19, 2017
Merged

Glob patterns #100

merged 4 commits into from
Nov 19, 2017

Conversation

pungggi
Copy link
Contributor

@pungggi pungggi commented Nov 16, 2017

This will solve a lot of pending issues related to high cpu usage, crashes and the need to exclude some folders. Especially the node_modules folder that, how state in some comments, should be excluded by default.

The PR creates an config option to exclude and one to only include a path to parse.
They can defined as Glob Patterns.

These are the issues that eventually can be closed:
#91
#62
maybe #64 ?
#47
#31
#27

src/fetcher.ts Outdated
const includeGlobPattern = vscode.workspace.getConfiguration().get('html-css-class-completion.includeGlobPattern');
const excludeGlobPattern = vscode.workspace.getConfiguration().get('html-css-class-completion.excludeGlobPattern');

return await vscode.workspace.findFiles(`${includeGlobPattern}.{${languages}}`, `${excludeGlobPattern}`);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the user decides to set the html-css-class-completion.includeGlobPattern setting to something like **/*.scss it will cause problems in the default pattern used inside the extension, resulting in something like **/*.scss.{css,html}, therefore, invaliding the search as a whole.

The change I'd like to suggest is to replace the default include pattern used by the extension whenever the user sets it through the html-css-class-completion.includeGlobPattern setting, just like you're doing for the excludeGlobPattern.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good points, i ll update my PR..

package.json Outdated
},
"html-css-class-completion.excludeGlobPattern": {
"type": "string",
"default": "node_modules∕*",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some people might be using npm to install front-end dependencies, it's better to keep "" as the default value. The performance problems related to memory and CPU usage were minimized by this change #90 already.

package.json Outdated
"properties": {
"html-css-class-completion.includeGlobPattern": {
"type": "string",
"default": "**/*",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the default value should be same as the one used internally by the extension: **/*.{css,html}.

@zignd
Copy link
Owner

zignd commented Nov 18, 2017

Sorry for taking this long to reply, I could only find some time to review it on my weekend.

@pungggi
Copy link
Contributor Author

pungggi commented Nov 19, 2017

Pull request updated

@zignd zignd merged commit 043fe52 into zignd:master Nov 19, 2017
@vfonic
Copy link

vfonic commented Dec 26, 2017

@zignd @pungggi How can I exactly use this configuration? I tried all of the following:

"css-class-completion.includeGlobPattern": ".meteor/local/build/programs/web.browser/merged-stylesheets.css",
"html-css-class-completion.includeGlobPattern": 
".meteor/local/build/programs/web.browser/merged-stylesheets.css",

"css-class-completion.includeGlobPattern": {
    "default": ".meteor/local/build/programs/web.browser/merged-stylesheets.css",
  }

"html-css-class-completion.includeGlobPattern": {
    "default": ".meteor/local/build/programs/web.browser/merged-stylesheets.css",
  }

But none work. In the code it's referred to as html-css-class-completion.includeGlobPattern:

const includeGlobPattern = vscode.workspace.getConfiguration().get('html-css-class-completion.includeGlobPattern');

"html-css-class-completion.includeGlobPattern": {

But in the readme it's css-class-completion.includeGlobPattern:
https://github.com/zignd/HTML-CSS-Class-Completion#usage

@zignd
Copy link
Owner

zignd commented Dec 27, 2017

Hi @vfonic, I have not released it yet. For some reason and I can't remember why. Anyway, thanks pointing out the error in the README.md, I will fix it and release a version containing this feature right now. If you check the README.md in the Marketplace, you will notice it doesn't have this section.

Regarding the usage, you need to use glob patterns, just like you do in the Search sidebar. You can also use multiple patterns and separate them by commas.

Search sidebar

@xianghongai
Copy link

xianghongai commented Apr 18, 2020

"html-css-class-completion.excludeGlobPattern": "**/node_modules/**,**/bower_components/**,src/vendor/**,src/view/**,src/plugin/**,src/assets/**",
"html-css-class-completion.includeGlobPattern": "src/view/**/*.html,src/page/**/*.html,src/scss/**/*.scss,src/lib/**/*.css",

not work...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants