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

Fix directory watchers when folding #162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions 0_dired_fs_observer.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,28 @@ def finish_refresh(view, paths):
self.paths.update({view: sorted(p for p in
set(old_paths + [p.rstrip(os.sep) for p in paths])
if os.path.exists(p))})
rewatch_all()

def fold(view, path):
path_without_sep = path.rstrip(os.sep)
path_with_sep = path_without_sep + os.sep
self.paths.update({
view: sorted(
p
for p in self.paths.get(view, [])
if (
p != path_without_sep
and not p.startswith(path_with_sep)
)
)
})
rewatch_all()

def rewatch_all():
self.observer.unschedule_all()
for p in reduce(lambda i, j: i + j, self.paths.values()):
self.observer.schedule(self.event_handler, p)

def fold(view, path):
p = set(self.paths.get(view, [])) - set([path.rstrip(os.sep)])
finish_refresh(view, list(p))

def toggle_watch_all(watch):
'''watch is boolean or None, global setting dired_autorefresh'''
views = self.paths.keys()
Expand Down