Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Support legit, real life negation - #29

Merged
benogle merged 8 commits into
masterfrom
bo-negate
Jul 24, 2015
Merged

benogle merged 8 commits into
masterfrom
bo-negate

Conversation

@benogle

@benogle benogle commented Jul 24, 2015

Copy link
Copy Markdown
Contributor

This is the path to finishing atom/find-and-replace#149 and does a couple things:

  • Supports more than one negated pattern in inclusions. It will move negated patterns to the exclusions list.
  • It adds a new exclusions list called globalExclusions. Global exclusions are the core.ignoredNames in atom. These patterns can be overridden by the inclusions.

Behavior

There are semi-complicated interactions with the inclusions, exclusions, and globalExclusions that need to work well. These are all supported by this PR. Consider the following tree:

/src/main.py
/src/main.pyc
/src/README.md
/test/test-main.py
/test/test-main.pyc
/vendor/somelib/somelib.py
/vendor/somelib/somelib.pyc
/vendor/somelib/README.md

Let's pretend we have ignoredNames set to vendor/, *.pyc, which means:

globalExclusions: ['vendor/', '*.pyc']

Without inclusions or exclusions set, it will search:

inclusions: []
exclusions: []
globalExclusions: ['vendor/', '*.pyc']

Paths Scanned:
/src/main.py
/src/README.md
/test/test-main.py

But we're totally over markdown files and dont want to search them, so we specify a negation of !*.md. This negation makes it into the exclusions list

inclusions: []
exclusions: ['*.md']
globalExclusions: ['vendor/', '*.pyc']

Paths Scanned:
/src/main.py
/test/test-main.py

And maybe we want to search vendor/. In this case, the vendor inclusion needs to override the vendor/ in globalExclusions. Otherwise, no results will show, and people will be confused. Also, we expect to still ignore *.pyc files.

inclusions: ['vendor']
exclusions: ['*.md']
globalExclusions: ['vendor/', '*.pyc']

Paths Scanned:
/src/main.py
/test/test-main.py
/vendor/somelib/somelib.py

Along the same lines, we might want to search pyc files. In this case, we still expect the vendor directory to be ignored.

inclusions: ['*.pyc']
exclusions: ['*.md']
globalExclusions: ['vendor/', '*.pyc']

Paths Scanned:
/src/main.py
/src/main.pyc
/test/test-main.py
/test/test-main.pyc

And finally, maybe we dont want to search in the tests directory, so lets add a new negation for that. At this point the paths input in find and replace would look like: vendor, !*.md, !test/

inclusions: ['vendor']
exclusions: ['*.md', 'test/']
globalExclusions: ['vendor/', '*.pyc']

Paths Scanned:
/src/main.py
/vendor/somelib/somelib.py

benogle added a commit that referenced this pull request Jul 24, 2015
Support legit, real life negation
@benogle
benogle merged commit 839305f into master Jul 24, 2015
@benogle
benogle deleted the bo-negate branch July 24, 2015 20:39
@benogle benogle mentioned this pull request Jul 24, 2015
benogle added a commit to atom/atom that referenced this pull request Jul 25, 2015
This adds solid negation and inclusion support. 
See atom/scandal#29
benogle added a commit to atom/atom that referenced this pull request Jul 25, 2015
This adds solid negation and inclusion support. 
See atom/scandal#29
benogle added a commit to atom/atom that referenced this pull request Jul 28, 2015
This adds solid negation and inclusion support. 
See atom/scandal#29
@ProLoser

Copy link
Copy Markdown

Yay 👍

@trusktr

trusktr commented Jun 21, 2016 •

Copy link
Copy Markdown

@benogle Hello, how do we specify the inclusions? So, is it just !exclusion, inclusion in the "File/directory pattern." field?

screen shot 2016-06-20 at 5 03 32 pm

And order matters?

Or maybe I'm missing something, do I actually write

inclusions: ['inclusion']
exclusions: ['exclusion']

somewhere?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants