Skip to content

Commit 55777d5

Browse files
committed
Exclude file|folder_exclude_patterns
If `use_global_exclude_patterns: true` is set, uses `folder_exclude_patterns` and `file_exclude_patterns` patterns (from global settings) to match against directories and files respectively, and not include them in the index.
1 parent a28e4e5 commit 55777d5

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,11 @@ such patterns:
301301
{ "dired_hidden_files_patterns": [".*", "__pycache__", "*.pyc"] }
302302
```
303303

304+
### Exclude Patterns
305+
306+
By default, FileBrowser shows all files and directories otherwise excluded by your `file_exclude_patterns` and `folder_exclude_patterns`.
307+
To exclude those set `use_global_exclude_patterns: true`
308+
304309
### VCS integration
305310
In case `git status`(or `hg status`) returns a colorable output in current directory, the modified
306311
and untracked files will be designated by orange and green icons respectively.

common.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,15 +386,20 @@ def prepare_filelist(self, names, path, goto, indent):
386386
level = indent * int((len(ind) / tab) + 1) if ind else indent
387387
files = []
388388
index_dirs = []
389+
exclude_dirs = self.view.settings().get('folder_exclude_patterns')
389390
index_files = []
391+
exclude_files = self.view.settings().get('file_exclude_patterns')
392+
use_exclude_patterns = self.view.settings().get('use_global_exclude_patterns')
390393
for name in names:
391394
full_name = join(path, goto, name)
392395
if isdir(full_name):
393-
index_dirs.append(u'%s%s' % (full_name, os.sep))
394-
items.append(''.join([level, u"▸ ", name, os.sep]))
396+
if use_exclude_patterns == None or use_exclude_patterns == True and not any(fnmatch.fnmatch(name, p) for p in exclude_dirs):
397+
index_dirs.append(u'%s%s' % (full_name, os.sep))
398+
items.append(''.join([level, u"▸ ", name, os.sep]))
395399
else:
396-
index_files.append(full_name)
397-
files.append(''.join([level, u"≡ ", name]))
400+
if use_exclude_patterns == None or use_exclude_patterns == True and not any(fnmatch.fnmatch(name, p) for p in exclude_files):
401+
index_files.append(full_name)
402+
files.append(''.join([level, u"≡ ", name]))
398403
index = index_dirs + index_files
399404
self.index = self.index[:self.number_line] + index + self.index[self.number_line:]
400405
items += files

0 commit comments

Comments
 (0)