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

folder_exclude_patterns is excluding all project folders named Settings #1895

Closed
evandrocoan opened this issue Sep 11, 2017 · 11 comments
Closed

Comments

@evandrocoan
Copy link

evandrocoan commented Sep 11, 2017

Summary

On my Sublime Project I got:

{
    "folders":
    [
        {
            "path": ".",
            "folder_exclude_patterns":
            [
                "Settings",
            ],
        },
    ]
}

So it should exclude the top level root folder Settings, but it is ignoring all folders everywhere on the project structure which is named settings or Settings.

I tried to do /Settings, ./Settings, but then it stop ignoring all the folders, including the root folder named Settings.

Related:

  1. Exclude folder in project root (only) #1115 Exclude folder in project root (only)
  2. folder_exclude_patterns relative to project root robcowie/SublimeTODO#77 folder_exclude_patterns relative to project root

Expected behavior

Only ignore the root folder when set ./Settings or /Settings on my .sublime-project

Actual behavior

Does not ignore the root folder when set ./Settings or /Settings on my .sublime-project

Steps to reproduce

  1. Create a My.sublime-project:
    {
        "folders":
        [
            {
                "path": ".",
                "folder_exclude_patterns":
                [
                    "Settings",
                ],
            },
        ]
    }
  2. Create the folder Settings on the top level
  3. Create the folder MyFolder/settings
  4. Sublime text will ignore both your top level ./Settings folder and nested MyFolder/settings folder.

It only should ignore the top level Settings folder. If I want to ignore nested folders, I should use */Settings or be able to ignore only the top level using .Settings or ./Settings or /Settings

Environment

  • Operating system and version:
    • Windows 10 build 15063 x64
    • Mac OS ...
    • Linux ...
  • Monitor:
    • Resolution 1920x1080
    • dpi_scale used in ST 1.0
  • Sublime Text:
    • Build 3142
    • 32 bit
evandrocoan added a commit to evandrocoan/ITE that referenced this issue Sep 11, 2017
Sublime Text is ignoring all folders names Settings everywhere.

Issue:
folder_exclude_patterns is excluding all project folders named Settings
sublimehq/sublime_text#1895
@FichteFoll
Copy link
Collaborator

I suspect the pattern is matched against the entire path, so you could try something like "Settings/*/settings". Maybe ** works also, but I never experimented with this setting.

@evandrocoan
Copy link
Author

This "Settings/*/settings" is a glob pattern? So doing it will ignore all the settings folders embedded on another settings folder, but this is the opposite of with I want to, which is only to ignore the folder:

image

But not the nested folder:

image

Currently doing:

{
    "folders":
    [
        {
            "path": ".",
            "folder_exclude_patterns":
            [
                "Settings",
            ],
        },
    ]
}

Will make Sublime Text to ignore both folders, not only the root folder Settings.

@evandrocoan
Copy link
Author

evandrocoan commented Sep 11, 2017

This is a bug on Sublime Text, which is putting the glob pattern * before the Settings name. The current behavior of Sublime text is interpret this:

{
    "folders":
    [
        {
            "path": ".",
            "folder_exclude_patterns":
            [
                "Settings",
            ],
        },
    ]
}

As this:

{
    "folders":
    [
        {
            "path": ".",
            "folder_exclude_patterns":
            [
                "*Settings",
            ],
        },
    ]
}

It only should interpret Settings as *Settings when I put a * before the name Settings.

@FichteFoll
Copy link
Collaborator

I experimented a bit. The following is what I could come up with.

  1. If a pattern does not contain either of /*?, it is directly matched against the folder name.

Now things get more complicated. All the following situations contain either /*? and ST preforms a full match on the entire path.

  1. * matches zero or more characters, including /.
  2. ? matches exactly one character, except /.
  3. ** has no special meaning.
  4. If a pattern does not start with / or *, * is prepended. (Useful for matching absolute paths.)
  5. If a pattern contains / (and does not contain *?), * is appended.

This still doesn't fit all the observed results, but it's an estimation for now.

What I don't understand is why *y/pa*ttern doesn't match yy/patternpattern but yy/pattern.

The observed results are as follows and could be used to write a test suite, for example:

Folder structure:

/tmp/sublime_project_tests/folder 1/
  pattern/
    x/
      pattern/
    xx/
      pattern/


Legend:

<pattern 1>
<pattern 2>
…
  <match 1>
  <match 2>
  …


Matches:

x/pattern
  folder 1/pattern/x/pattern/

x*/pattern
*x/pattern
  folder 1/pattern/x/pattern/
  folder 1/pattern/xx/pattern/

pattern
*pattern
*/pattern
folder 1/
  folder 1/pattern/

/pattern
folder 1
  <nothing>

pattern/x
pat?ern/x
pat*n/x
pattern/
  folder 1/pattern/x/
  folder 1/pattern/xx/

---

Folder Structure:

/tmp/sublime_project_tests/folder 2/
  xy/
  xyx/
  y/
    pattern/
  yy/
    pattern/
    patternpattern/
    y/
      pattern/


Matches:

folder 2/x
folder 2/xy
folder 2/x*
  folder 2/xy/
  folder 2/xyx/

folder*
folder 2/x*/
/pattern
/tmp/
/tmp
  <nothing>

folder*/
/tmp/*
  folder 2/xy/
  folder 2/xyx/
  folder 2/y/
  folder 2/yy/

folder 2/*/
  folder 2/y/pattern
  folder 2/yy/pattern
  folder 2/yy/patternpattern
  folder 2/yy/y/


folder 2/*/pattern
*pattern
y*/pattern
  folder 2/y/pattern
  folder 2/yy/pattern
  folder 2/yy/patternpattern
  folder 2/yy/y/pattern

pattern
*/pattern
*y/pattern
*y/pa*ttern
*/*y/pa*ttern
*/*/*/*/*y/pattern
  folder 2/y/pattern
  folder 2/yy/pattern
  folder 2/yy/y/pattern

*/*/*/*/*/*y/pattern
  folder 2/yy/y/pattern

evandrocoan added a commit to evandrocoan/ITE that referenced this issue Sep 11, 2017
@evandrocoan
Copy link
Author

evandrocoan commented Sep 11, 2017

Thanks for the insights! I managed to fix this prepending Data/ on the Settings entry. But this fix depends on the project root folder being named Data for the folder_exclude_patterns to work.

The folder_exclude_patterns should accept the entry . to represent the current folder as in:

{
    "folders":
    [
        {
            "path": ".",
        },
    ]
}

So to ignore some folder I would use:

{
    "folders":
    [
        {
            "path": ".",
            "folder_exclude_patterns":
            [
                "./Settings/*",
            ],
        },
    ]
}

To ignore a root folder not depending on the current folder . name.

Currently I did was:

{
    "folders":
    [
        {
            "path": ".",
            "folder_exclude_patterns":
            [
                "Data/Settings",
            ],
        },
    ]
}

Where Data is the name of the current folder . where the .sublime-project is on. Appending * on settings also works, but appending /* do not work as * to ignore the folder Settings.

@FichteFoll
Copy link
Collaborator

I suggest opening a new issue for the ./ feature request. This issue seems more like the result of poor documentation.

@danny-andrews
Copy link

I ran into this issue today. Behavior seems very counter-intuitive. Is there any documentation on what format these "patterns" should be in, because it doesn't seem to be glob.

@tajmone
Copy link

tajmone commented Nov 3, 2018

As @danny-andrews pointed out, documentation should be provided. The projects page at the official documentation is starving, and hunting on Google for clues on how to use settings and patterns will inevitably result in forums posts and Issues which might not mirror the current state of latest ST3.

Please, use the official ST3 documentation to actually store always up to date (and detailed) info on how to use settings and features.

@FichteFoll
Copy link
Collaborator

I believe the experiments I presented earlier in this issue are the most detailed documentation available currently.

@cutephoton
Copy link

cutephoton commented Jul 27, 2019

After working through this over 2 hours, I went back and looked at the documentation. Aside from knowing variable names, it almost entirely fails to document most aspects of its operation and the relationship of project, folder, and patterns. Although it is still useful, its inability to handle pretty simple, common directory layouts is surprising. I concur with those remarking that it is counter-intuitive. It is. Can a reasonably experienced engineer figure the quirks out solely with the documentation provided by sublime? Pretty sure the answer is not within a reasonable period of time.

I encourage improvements to the documentation. Further, guidance on specific common issues and strategies to resolve them. In the documentation. Or make a better glob. Something. Looks like this or variants of it has confused and confounded people going on 6 years now.

@wbond
Copy link
Member

wbond commented Feb 14, 2020

As of build 4067, patterns can use // to anchor to the project folder root. This way you can use //Settings/.

Additionally, documentation will be posted soon that outlines the file pattern features and behavior. There are some slight behavior tweaks between 4067 and all previous builds, and the documentation will include info about both.

@wbond wbond closed this as completed Feb 14, 2020
@wbond wbond added the R: fixed label Feb 14, 2020
@wbond wbond added this to the Build 4067 milestone Feb 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants