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

Support regex in files.exclude => when #1214

Open
altano opened this issue Dec 12, 2015 · 12 comments
Open

Support regex in files.exclude => when #1214

altano opened this issue Dec 12, 2015 · 12 comments
Assignees
Labels
feature-request Request for new features or functionality file-explorer Explorer widget issues file-glob File glob engine
Milestone

Comments

@altano
Copy link

altano commented Dec 12, 2015

I would like to ignore JS files in my project when there's a matching TS or matching TSX file. Right now I have to choose one or the other. Please support making the "when" directive in the "files.exclude" workspace setting use a regex, so I could do this:

{
  "files.exclude": {
        "**/*.js": { "when": "$(basename).tsx?"},
  }
}
@altano
Copy link
Author

altano commented Dec 12, 2015

You may also want to add "when" to the docs.

@egamma egamma added the feature-request Request for new features or functionality label Dec 12, 2015
@egamma egamma added this to the Backlog milestone Dec 12, 2015
@egamma
Copy link
Member

egamma commented Dec 12, 2015

There is a work around 😄. Define define different regular expression that matches the same files:

{
    "files.exclude": {
        "**/*.js": { "when": "$(basename).ts"},
        "**/*?.js": { "when": "$(basename).tsx"}
    }
}

@bpasero can you pls check that we cover when in our docs.

@bpasero
Copy link
Member

bpasero commented Dec 12, 2015

@massimocode
Copy link

+1 on this issue, although the workaround suggested by @egamma works for me

@sparebytes
Copy link

sparebytes commented Mar 6, 2017

I would like to ignore *.d.ts when there is a corresponding .ts file. Unfortunately this rule just hides all d.ts files:

"src/**/*.d.ts": { "when": "$(basename).ts" },

Apparently, $(basename) doesn't match the * in *.d.ts but instead matches *.dt. This could be fixed using regular expressions (negative lookahead). A new variable like $(matchedname) might solve it but I see other problems with that approach.

@paranoidjk
Copy link

+1 want this feature too.

@paranoidjk
Copy link

and want search.exclude to support when too

@igrek8
Copy link

igrek8 commented Aug 3, 2017

@sparebytes seems like no further investigation has been made :( also looking forward to flexible exclusion

@nevir
Copy link

nevir commented May 18, 2018

This would be extremely helpful in a lot of cases:

  • Hiding .d.ts files w/o a corresponding .ts
  • Hiding .js.map files w/o a corresponding .ts
  • Excluding specific directories (could be used to work around Exclude all files except for... #869)

@bpasero bpasero added the file-glob File glob engine label Sep 21, 2018
@isidorn isidorn self-assigned this Oct 8, 2019
@anru
Copy link

anru commented Jul 9, 2020

It is here: https://code.visualstudio.com/docs/languages/typescript#_hiding-derived-javascript-files

No more actual. Also for consistency reasons I would expect read about when on this page: https://code.visualstudio.com/docs/getstarted/settings

@qarthandgi
Copy link

This is still an important issue that needs to be addressed. Being able to hide derived .ts and .tsx together is a common need.

Also, I've been searching for hours for any documentation about the when clause and have yet to find any.

+1

@marsiancba
Copy link

+1

Problem with mentioned workaround (use 2 glob patterns for js) is that it works only in Explorer but does not work in Search.
In Search it seems to find first glob pattern, then checks when and then breaks from loop, so it does not check the second glob/when combination.

@lramos15 lramos15 assigned lramos15 and unassigned JacksonKearl May 25, 2022
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 file-explorer Explorer widget issues file-glob File glob engine
Projects
None yet
Development

No branches or pull requests