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

Improved support for globs in multiroot workspace #1083

Merged
merged 7 commits into from
Oct 13, 2022

Conversation

riccardoferretti
Copy link
Collaborator

@riccardoferretti riccardoferretti commented Oct 13, 2022

Fixes #1063 #959

Replaces #1065

Currently globs are applied equally to all workspace folders
This approach is backwards compatible with single-root workspaces (and existing configuration)
It adds the possibility of limiting the glob to one of the directories by starting the glob pattern with the directory name.

Seems to be a bit of a complicated topic even within VS Code itself, see microsoft/vscode#82145 (comment) (amongst others)

How it works

In case there is more than one workspace folder, the glob can include the folder name to limit its application to that folder. If the glob is generic it still applies to all folders. For example, given:

notes/
  family/
    family.md
  business/
    business.md
  random/
    family-note.md

and

work/
  company/
    file.md
  side-project/
    project.md
  random/
    work-note.md

Given the random/** glob

  1. if only the notes folder is open it will ignore everything inside the random directory (current behavior)
  2. if both directories are open, it will ignore everything inside notes/random and work/random (current behavior)

If I only want to only ignore the random directory in notes, this was not possible.
With this PR, I can use the glob notes/random/** to target only one of the root directories.

Can it be confusing? Maybe but I am optimistic it won't:
when the workspace has a single folder, you don't see the folder in the explorer, so intuitively you wouldn't use it in your glob (which is also the behavior today, and the reason why on simple projects we haven't had issues).

image

When the workspace has more than a folder, then they show up in the explorer, so it does "feel" more right to include it in the glob

image

So the root folder "becomes" part of the explorer, and in the same way I can see how it could "become" part of the glob.

If a glob doesn't match a specific workspace folder it will apply equally to all of them (as it is today).

@riccardoferretti riccardoferretti merged commit 8fe8692 into master Oct 13, 2022
@riccardoferretti riccardoferretti deleted the feature/multi-root-glob-support branch October 13, 2022 16:49
phil0522 pushed a commit to phil0522/foam that referenced this pull request Nov 24, 2022
* Added path util to resolve absolute path from multiple base directories
* Better support for multiple roots in include/ignore globs
* URI.asAbsolutePath to use path utils
* Lint
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.

Exclude whole repo/Folder when using foam in a multi-root workspace
1 participant