diff --git a/README.md b/README.md index 1a9b156a..e334b6a4 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,11 @@ or delete files and folders. ![](https://f.cloud.github.com/assets/671378/2241932/6d9cface-9ceb-11e3-9026-31d5011d889d.png) +This package uses both the `core.ignoredNames` and `tree-view.ignoredNames` +config settings to filter out files and folders that will not be shown. +Both of those config settings are interpreted as arrays of +[minimatch](https://github.com/isaacs/minimatch) glob patterns. + ## API The Tree View displays icons next to files. These icons are customizable by installing a package that provides an `atom.file-icons` service. diff --git a/lib/tree-view.coffee b/lib/tree-view.coffee index 5fceed45..66ccb147 100644 --- a/lib/tree-view.coffee +++ b/lib/tree-view.coffee @@ -143,6 +143,10 @@ class TreeView extends View @updateRoots() @disposables.add atom.config.onDidChange 'tree-view.hideIgnoredNames', => @updateRoots() + @disposables.add atom.config.onDidChange 'tree-view.mergeIgnoredNames', => + @updateRoots() if atom.config.get('tree-view.hideIgnoredNames') + @disposables.add atom.config.onDidChange 'tree-view.ignoredNames', => + @updateRoots() if atom.config.get('tree-view.hideIgnoredNames') @disposables.add atom.config.onDidChange 'core.ignoredNames', => @updateRoots() if atom.config.get('tree-view.hideIgnoredNames') @disposables.add atom.config.onDidChange 'tree-view.showOnRightSide', ({newValue}) => @@ -248,8 +252,10 @@ class TreeView extends View Minimatch ?= require('minimatch').Minimatch - ignoredNames = atom.config.get('core.ignoredNames') ? [] - ignoredNames = [ignoredNames] if typeof ignoredNames is 'string' + ignoredNames = atom.config.get('tree-view.ignoredNames') ? [] + if atom.config.get('tree-view.mergeIgnoredNames') + ignoredNames = ignoredNames.concat(atom.config.get('core.ignoredNames') ? []) + for ignoredName in ignoredNames when ignoredName try @ignoredPatterns.push(new Minimatch(ignoredName, matchBase: true, dot: true)) diff --git a/package.json b/package.json index 49c500c7..d0977b27 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,17 @@ "hideIgnoredNames": { "type": "boolean", "default": false, - "description": "Don't show items matched by the `Ignored Names` core config setting." + "description": "Don't show items matched by the `Ignored Names` config setting." + }, + "mergeIgnoredNames": { + "type": "boolean", + "default": true, + "description": "Merge the `Ignored Names` of this package with the `Ignored Names` from the core configuration setting." + }, + "ignoredNames": { + "type": "array", + "default": [], + "description": "List of string glob patterns. Files and directories matching these patterns will be ignored. This list is merged with the list defined by the core `Ignored Names` config setting, if the `Merge Ignored Names` setting is on. Example: `.git, ._*, Thumbs.db`." }, "showOnRightSide": { "type": "boolean", diff --git a/spec/tree-view-spec.coffee b/spec/tree-view-spec.coffee index 6b182db3..175cf1ee 100644 --- a/spec/tree-view-spec.coffee +++ b/spec/tree-view-spec.coffee @@ -2212,6 +2212,7 @@ describe "TreeView", -> atom.config.set "tree-view.hideIgnoredNames", false it "hides ignored files if the option is set, but otherwise shows them", -> + atom.config.set("tree-view.mergeIgnoredNames", true) expect(treeView.find('.directory .name:contains(.git)').length).toBe 1 expect(treeView.find('.directory .name:contains(test.js)').length).toBe 1 expect(treeView.find('.directory .name:contains(test.txt)').length).toBe 1 @@ -2226,6 +2227,25 @@ describe "TreeView", -> expect(treeView.find('.directory .name:contains(test.js)').length).toBe 1 expect(treeView.find('.directory .name:contains(test.txt)').length).toBe 1 + it "ignores paths that match entries in config.tree-view.ignoredNames", -> + atom.config.set("core.ignoredNames", []) + atom.config.set("tree-view.hideIgnoredNames", true) + atom.config.set("tree-view.ignoredNames", ["*.txt"]) + expect(treeView.find('.directory .name:contains(test.js)').length).toBe 1 + expect(treeView.find('.directory .name:contains(test.txt)').length).toBe 0 + + it "does not ignore paths that match entries from config.core.ignoredNames if the setting to merge them is off, otherwise it does ignore them", -> + atom.config.set("core.ignoredNames", ["*.js"]) + atom.config.set("tree-view.hideIgnoredNames", true) + atom.config.set("tree-view.mergeIgnoredNames", true) + atom.config.set("tree-view.ignoredNames", ["*.txt"]) + expect(treeView.find('.directory .name:contains(test.js)').length).toBe 0 + expect(treeView.find('.directory .name:contains(test.txt)').length).toBe 0 + + atom.config.set("tree-view.mergeIgnoredNames", false) + expect(treeView.find('.directory .name:contains(test.js)').length).toBe 1 + expect(treeView.find('.directory .name:contains(test.txt)').length).toBe 0 + describe "the squashedDirectoryName config option", -> beforeEach -> rootDirPath = fs.absolute(temp.mkdirSync('tree-view'))