From 9207e83c0672c6b8b49fce3b621197fb1e77b2be Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 17 Mar 2010 12:38:21 +0100 Subject: fixed #69: tab completion breaks with Apps subclass --- TODO | 2 +- ranger/api/apps.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index 964cccc9..f20d542e 100644 --- a/TODO +++ b/TODO @@ -70,7 +70,7 @@ Bugs (X) #62 10/02/15 curs_set can raise an exception (X) #65 10/02/16 "source ranger ranger some/file.txt" shouldn't cd after exit ( ) #67 10/03/08 terminal title in tty - ( ) #69 10/03/11 tab-completion breaks with Apps subclass + (X) #69 10/03/11 tab-completion breaks with Apps subclass Ideas diff --git a/ranger/api/apps.py b/ranger/api/apps.py index e61b5e2c..a17a6601 100644 --- a/ranger/api/apps.py +++ b/ranger/api/apps.py @@ -112,8 +112,12 @@ class Applications(FileManagerAware): def all(self): """Returns a list with all application functions""" - methods = self.__class__.__dict__ - return [meth[4:] for meth in methods if meth.startswith('app_')] + result = set() + # go through all the classes in the mro (method resolution order) + # so subclasses will return the apps of their superclasses. + for cls in self.__class__.__mro__: + result |= set(m[4:] for m in cls.__dict__ if m.startswith('app_')) + return sorted(result) def tup(*args): -- cgit 1.4.1-2-gfad0