summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2017-10-12 19:05:32 +0100
committermathieui <mathieui@mathieui.net>2017-10-13 00:07:06 +0200
commit6626208983e0360c4dadfc4d615b34a819c793f7 (patch)
tree71c4d5386d8bfa4c97b32c335bae71135791f60f
parent3317604c6544a488bec749c06a52382971b60790 (diff)
downloadpoezio-6626208983e0360c4dadfc4d615b34a819c793f7.tar.gz
poezio-6626208983e0360c4dadfc4d615b34a819c793f7.tar.bz2
poezio-6626208983e0360c4dadfc4d615b34a819c793f7.tar.xz
poezio-6626208983e0360c4dadfc4d615b34a819c793f7.zip
Change tab search behavior to select first matching tab, and cycle back the list.
-rw-r--r--poezio/core/commands.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/poezio/core/commands.py b/poezio/core/commands.py
index b08a082f..e31d8e59 100644
--- a/poezio/core/commands.py
+++ b/poezio/core/commands.py
@@ -211,19 +211,17 @@ class CommandCore:
return
self.core.current_tab_nb = number
else:
- matchs = []
- target_tabs = self.core.tabs[self.core.current_tab_nb+1:]
- if not target_tabs:
- target_tabs = self.core.tabs
+ match = None
+ target_tabs = self.core.tabs[self.core.current_tab_nb+1:] \
+ + self.core.tabs[:self.core.current_tab_nb]
for tab in target_tabs:
for tab_name in tab.matching_names():
if tab_name[1] and name in tab_name[1].lower():
- matchs.append((tab_name[0], tab))
- if not matchs:
+ match = tab
+ if match is None:
self.core.previous_tab_nb = prev_nb
return
- tab = min(matchs, key=lambda m: m[0])[1]
- self.core.current_tab_nb = tab.nb
+ self.core.current_tab_nb = match.nb
old_tab.on_lose_focus()
self.core.current_tab().on_gain_focus()
self.core.refresh_window()