summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--doc/ranger.pod5
-rw-r--r--ranger/config/rc.conf4
-rw-r--r--ranger/container/settings.py1
-rw-r--r--ranger/gui/widgets/view_base.py21
4 files changed, 26 insertions, 5 deletions
diff --git a/doc/ranger.pod b/doc/ranger.pod
index 523d8d9d..71a9342d 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -791,6 +791,11 @@ this pattern will hide all files that start with a dot or end with a tilde.
 
  set hidden_filter ^\.|~$
 
+=item hint_collapse_threshold [int]
+
+The key hint lists up to this size have their sublists expanded.
+Otherwise the submaps are replaced with "...".
+
 =item idle_delay [integer]
 
 The delay that ranger idly waits for user input, in milliseconds, with a
diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf
index 676090fb..fe00c7c0 100644
--- a/ranger/config/rc.conf
+++ b/ranger/config/rc.conf
@@ -216,6 +216,10 @@ set cd_tab_fuzzy false
 # disable this feature.
 set preview_max_size 0
 
+# The key hint lists up to this size have their sublists expanded.
+# Otherwise the submaps are replaced with "...".
+set hint_collapse_threshold 10
+
 # Add the highlighted file to the path in the titlebar
 set show_selection_in_titlebar true
 
diff --git a/ranger/container/settings.py b/ranger/container/settings.py
index d0b094d0..8b7364a2 100644
--- a/ranger/container/settings.py
+++ b/ranger/container/settings.py
@@ -45,6 +45,7 @@ ALLOWED_SETTINGS = {
     'freeze_files': bool,
     'global_inode_type_filter': str,
     'hidden_filter': str,
+    'hint_collapse_threshold' : int,
     'hostname_in_titlebar': bool,
     'idle_delay': int,
     'iterm2_font_width': int,
diff --git a/ranger/gui/widgets/view_base.py b/ranger/gui/widgets/view_base.py
index b005f1d5..0878ab0f 100644
--- a/ranger/gui/widgets/view_base.py
+++ b/ranger/gui/widgets/view_base.py
@@ -132,7 +132,7 @@ class ViewBase(Widget, DisplayableContainer):  # pylint: disable=too-many-instan
             """
             from itertools import groupby
 
-            # groupby needs the list to be sorted
+            # groupby needs the list to be sorted.
             hints.sort(key=lambda t: t[0])
 
             def group_hints(hints):
@@ -147,13 +147,24 @@ class ViewBase(Widget, DisplayableContainer):  # pylint: disable=too-many-instan
                         in groupby(
                             hints,
                             key=first_key))
-            hints = sorted(
-                group_hints(hints),
-                key=lambda g: g[0][1])  # sort by the first action in group
+
+            grouped_hints = group_hints(hints)
+
+            # If there are too many hints, collapse the sublists.
+            if len(hints) > self.fm.settings.hint_collapse_threshold:
+                def first_key_in_group(group):
+                    return group[0][0][0]
+                grouped_hints = [[(first_key_in_group(hint_group), "...")]
+                               if len(hint_group) > 1
+                               else hint_group
+                               for hint_group in grouped_hints]
+
+            # Sort by the first action in group.
+            grouped_hints = sorted(grouped_hints, key=lambda g: g[0][1])
 
             def flatten(nested_list):
                 return [item for inner_list in nested_list for item in inner_list]
-            return flatten(hints)
+            return flatten(grouped_hints)
         hints = sort_hints(hints)
 
         hei = min(self.hei - 1, len(hints))