summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2012-09-27 19:08:59 +0200
committermathieui <mathieui@mathieui.net>2012-09-27 19:08:59 +0200
commit020e6478e38630fa6629b4d62aa4d5ae157424f8 (patch)
treedafecfcfab5a08cb2e173df22b8c099a4334c900 /src
parent8921fea38f3ede4ecea8da07245dc3417ebb7883 (diff)
downloadpoezio-020e6478e38630fa6629b4d62aa4d5ae157424f8.tar.gz
poezio-020e6478e38630fa6629b4d62aa4d5ae157424f8.tar.bz2
poezio-020e6478e38630fa6629b4d62aa4d5ae157424f8.tar.xz
poezio-020e6478e38630fa6629b4d62aa4d5ae157424f8.zip
Fix the bug of Alt-e (go to important room)
Diffstat (limited to 'src')
-rw-r--r--src/core.py27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/core.py b/src/core.py
index d23193b8..f3a0046e 100644
--- a/src/core.py
+++ b/src/core.py
@@ -795,13 +795,28 @@ class Core(object):
Go to the next room with activity, in the order defined in the
dict tabs.STATE_PRIORITY
"""
+ # shortcut
priority = tabs.STATE_PRIORITY
- sorted_tabs = sorted(self.tabs, key=lambda tab: priority[tab.state],
- reverse=True)
- tab = sorted_tabs.pop(0) if sorted_tabs else None
- if priority[tab.state] < 0 or not tab:
- return
- self.command_win('%s' % tab.nb)
+ tab_refs = {}
+ # put all the active tabs in a dict of lists by state
+ for tab in self.tabs:
+ if not tab:
+ continue
+ if tab.state not in tab_refs:
+ tab_refs[tab.state] = [tab]
+ else:
+ tab_refs[tab.state].append(tab)
+ # sort the state by priority and remove those with negative priority
+ states = sorted(tab_refs.keys(), key=(lambda x: priority.get(x, 0)), reverse=True)
+ states = [state for state in states if priority.get(state, -1) >= 0]
+
+ for state in states:
+ for tab in tab_refs[state]:
+ if tab.nb < self.current_tab_nb and tab_refs[state][-1].nb > self.current_tab_nb:
+ continue
+ self.command_win('%s' % tab.nb)
+ return
+ return
def focus_tab_named(self, tab_name):
for tab in self.tabs: