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

Multi-Root Workspace: Exclude Subfolders #82145

Closed
chriszwickerocteris opened this issue Oct 9, 2019 · 13 comments
Closed

Multi-Root Workspace: Exclude Subfolders #82145

chriszwickerocteris opened this issue Oct 9, 2019 · 13 comments
Labels
feature-request Request for new features or functionality *out-of-scope Posted issue is not in scope of VS Code workbench-multiroot Multi-root (multiple folders) issues

Comments

@chriszwickerocteris
Copy link

Similar to what #45470 is asking for, I would like to exclude certain folders from my multi-root workspace layout, mainly those subfolders that are mounted as root folders themselves, but sometimes also other files / folders.

I suggest simply adding an ignore section, e.g.

{
  "folders": [
    {
      "path": "foo",
      "ignore": [
        "baz/"
      ]
    },
    {
      "path": "bar"
    },
    {
      "path": "foo/baz"
    },
    {
      "name": "Root",
      "path": ".",
      "ignore": [
        "foo/",
        "bar/",
        ".git/"
      ]
    }
  ],
  "settings": {}
}
@bpasero bpasero added feature-request Request for new features or functionality workbench-multiroot Multi-root (multiple folders) issues labels Oct 9, 2019
@bpasero bpasero removed their assignment Oct 9, 2019
@bpasero bpasero added the *out-of-scope Posted issue is not in scope of VS Code label Oct 9, 2019
@vscodebot
Copy link

vscodebot bot commented Oct 9, 2019

This issue is being closed to keep the number of issues in our inbox on a manageable level, we are closing issues that are not going to be addressed in the foreseeable future: We look at the number of votes the issue has received and the number of duplicate issues filed. More details here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.

If you wonder what we are up to, please see our roadmap and issue reporting guidelines.

Thanks for your understanding and happy coding!

@vscodebot vscodebot bot closed this as completed Oct 9, 2019
@chriszwickerocteris
Copy link
Author

I'm a bit confused by how this is being handled:

@rucoder
Copy link

rucoder commented Jan 28, 2020

up vote for the feature

@pacifier007
Copy link

These feature requests keep getting marked as out-of-scope with no explanation. It's a perfectly valid and needed feature. Example, my use-case here: #91102 (comment)

Related tickets:
#50638
#48262

@gnowland
Copy link

I agree, it would be great to be able to add a folder but exclude its sub-folders if we only want to work with the *files* within said folder, but not sub-folders.

@dfoverdx
Copy link

I figured out the solution that's mentioned in the documentation but poorly (arguably never) explained. I leave a comment here for the next sorry dev that comes looking for it.

In the root of the workspace folder in which you want to exclude files, create the .vscode/settings.json. In this file, you can set files.exclude and it will only apply to that workspace folder, even if other workspace folders are subdirectories.

File tree

/
┣ .vscode/
┃ ┗ settings.json
┣ sub-dir/
┃ ┗ index.js
┗ workspace.code-workspace

workspace.code-workspace

{
  "folders": [
    { "path": "./", "name": "root" },
    { "path": "./sub-dir" },
  ]
}

./.vscode/settings.json

{
  "files.exclude": {
    "**/.git": true,
    "**/.svn": true,
    "**/.hg": true,
    "**/CVS": true,
    "**/.DS_Store": true,
    "sub-dir": true,
  },
}

The explorer will now show two workspace roots: root and sub-dir. Under root, ./sub-dir is not listed. Under sub-dir, all of its files are listed.

File explorer screenshot

@Axelfoley85
Copy link

It is also possible to include these settings into the workspace configuration

{
	"folders": [
		{
			"path": "sub-fold"
		},
		{
			"name": "root",
			"path": ".",
		},
	],
	"settings": {
		"files.exclude": {
			"sub-fold": true,
		},
	}
}

@stratboy
Copy link

I think this issue is still not addressed very well.
And guys, I think we all want just the same settings syntax that Sublime Text has.
Or, anyway, what chriszwickerocteris is suggesting on his original post.

@FedericoBiccheddu
Copy link

I did resolve the issue following dfoverdx's instructions.

My goal was to hide source folders in the root, but keep them in their own sub-folder because the have the same name:

.
├── config
├── Makefile
└── source
    ├── sub-folder-1
    │   ├── package.json
    │   ├── source
    │   └── tsconfig.json
    └── sub-folder-2
        ├── config
        ├── package.json
        ├── source
        └── tsconfig.json

Adding files.exclude in the workspace, setting is propagated to sub-folders. In my case source folder was hidden in both root and sub-folders. Adding it in settings.json resolved this issue.

@thomasoatman
Copy link

It is nice that the exclude setting was added. But I can't figure out how to ignore only Folders.
I have too many folders (and they can get added and removed at any time) to name each of them.
Using glob wildcards though hides FILES too.
Frankly I would love a setting to not show subfolders at all.
But if there is a way to tell am Exclude entry to only match folders, that would be wonderful too.

I tried this expression hoping it would only exclude names that include a '.':
"**/[/[,_,0-9,A-Z,a-z]*[^.]*": true,

but it effectively hid everything.

Would also be cool to exclude 'empty' folders. For instance, I have a subfolder 'graphics' that has jpg files. I exclude *.jpg, but the graphics folder (now empty) still shows -- kindof useless....

@studgeek
Copy link

@Axelfoley85 I'm sorry, I'm not following how your example works in practice. For example given the following I still see roota/subfold in my vscode explorer. Thx!

"folders": [
		{
			"path": "../../roota"
		},
		{
			"path": "../../rootb"
		}
	],
"settings": {
        "files.exclude": {
              "../../roota/subfold": true,
       }

@Axelfoley85
Copy link

Axelfoley85 commented May 21, 2024

@Axelfoley85 I'm sorry, I'm not following how your example works in practice. For example given the following I still see roota/subfold in my vscode explorer. Thx!

"folders": [
		{
			"path": "../../roota"
		},
		{
			"path": "../../rootb"
		}
	],
"settings": {
        "files.exclude": {
              "../../roota/subfold": true,
       }

Ok, @studgeek

not sure but would it be a difference if you did this instead?

"folders": [
 		    {
 			"path": "../../roota/subfold"
 		},
		{
 			"path": "../../rootb"
 		}
 	], 
"settings": { 
"files.exclude": { 
"../../roota/subfold": true, 
}

Sorry for bad formatting on mobile.

@studgeek
Copy link

Thanks. I still want to view the rest of roota in the workspace though. To be honest, I'm not seeing what the value is of adding a folder to a multi-root workspace and then excluding that whole folder?

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 *out-of-scope Posted issue is not in scope of VS Code workbench-multiroot Multi-root (multiple folders) issues
Projects
None yet
Development

No branches or pull requests