From 9480940bbfd2a7631d358bc0dd8d2f32dc0b7714 Mon Sep 17 00:00:00 2001 From: "A. Lopes" Date: Wed, 10 Jun 2015 22:04:06 +0100 Subject: Fix for issue #259. If all the contents of the current folder are hidden, now when the user toggle show_hidden, the topmost file or directory is automatically selected. If the user toggles show_hidden, hiding all files and folders those files can now not be interacted with. --- ranger/container/directory.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ranger/container/directory.py b/ranger/container/directory.py index b851eece..52b494d5 100644 --- a/ranger/container/directory.py +++ b/ranger/container/directory.py @@ -229,6 +229,15 @@ class Directory(FileSystemObject, Accumulator, Loadable): filters.append(lambda file: temporary_filter_search(file.basename)) self.files = [f for f in self.files_all if accept_file(f, filters)] + + # A fix for corner cases when the user invokes show_hidden on a + # directory that contains only hidden directories and hidden files. + if self.files and not self.pointed_obj: + self.pointed_obj = self.files[0] + elif not self.files: + self.content_loaded = False + self.pointed_obj = None + self.move_to_obj(self.pointed_obj) # XXX: Check for possible race conditions -- cgit 1.4.1-2-gfad0