Skip to content

Commit 8e80529

Browse files
committed
Exclude file/folder_exclude_patterns
If `dired_show_excluded_files` is set to `false`, it hides files and folders that match against `folder_exclude_patterns` and `file_exclude_patterns` patterns defined in the global settings.
1 parent a28e4e5 commit 8e80529

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

README.md

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

304+
It also shows all files and directories otherwise excluded by your `file_exclude_patterns` and `folder_exclude_patterns`.
305+
306+
To hide excluded files and folders, add the following to your settings:
307+
``` json
308+
{ "dired_show_excluded_files": false }
309+
```
310+
304311
### VCS integration
305312
In case `git status`(or `hg status`) returns a colorable output in current directory, the modified
306313
and untracked files will be designated by orange and green icons respectively.

common.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -403,21 +403,29 @@ def prepare_filelist(self, names, path, goto, indent):
403403
def is_hidden(self, filename, path, goto=''):
404404
if not (path or goto): # special case for ThisPC
405405
return False
406-
tests = self.view.settings().get('dired_hidden_files_patterns', ['.*'])
407-
if isinstance(tests, str):
408-
tests = [tests]
409-
if any(fnmatch.fnmatch(filename, pattern) for pattern in tests):
410-
return True
411-
if sublime.platform() != 'windows':
412-
return False
413-
# check for attribute on windows:
414-
try:
415-
attrs = ctypes.windll.kernel32.GetFileAttributesW(join(path, goto, filename))
416-
assert attrs != -1
417-
result = bool(attrs & 2)
418-
except (AttributeError, AssertionError):
419-
result = False
420-
return result
406+
show_hidden = self.show_hidden
407+
show_excluded = self.view.settings().get('dired_show_excluded_files', True)
408+
is_hidden = False
409+
if not show_hidden:
410+
test = self.view.settings().get('dired_hidden_files_patterns', ['.*'])
411+
if isinstance(test, str):
412+
test = [test]
413+
if any(fnmatch.fnmatch(filename, p) for p in test):
414+
is_hidden = True
415+
if sublime.platform() == 'windows':
416+
# check for attribute on windows:
417+
try:
418+
attrs = ctypes.windll.kernel32.GetFileAttributesW(join(path, goto, filename))
419+
assert attrs != -1
420+
if bool(attrs & 2):
421+
is_hidden = True
422+
except:
423+
pass
424+
if not show_excluded:
425+
test = self.view.settings().get('folder_exclude_patterns', []) + self.view.settings().get('file_exclude_patterns', [])
426+
if any(fnmatch.fnmatch(filename, p) for p in test):
427+
is_hidden = True
428+
return is_hidden
421429

422430
def try_listing_directory(self, path):
423431
'''Return tuple of two element

0 commit comments

Comments
 (0)