Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Limit thread focus loop by time, not threads. #1519

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions alot/buffers/search.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright (C) 2011-2018 Patrick Totzke <[email protected]>
# This file is released under the GNU GPL, version 3 or a later revision.
# For further details see the COPYING file
import time

import urwid
from notmuch2 import NotmuchError

Expand Down Expand Up @@ -99,13 +101,13 @@ def consume_pipe(self):
while not self.threadlist.empty:
self.threadlist._get_next_item()

def consume_pipe_until(self, predicate, limit=0):
n = limit
while not limit or n > 0:
def consume_pipe_until(self, predicate, timeout=1):
start = time.monotonic()
timeout_time = start + timeout
while time.monotonic() < timeout_time:
if self.threadlist.empty \
or predicate(self.threadlist._get_next_item()):
break
n -= 1

def focus_first(self):
if not self.reversed:
Expand All @@ -130,8 +132,7 @@ def focus_last(self):
def focus_thread(self, thread):
tid = thread.get_thread_id()
self.consume_pipe_until(lambda w:
w and w.get_thread().get_thread_id() == tid,
self.search_threads_rebuild_limit)
w and w.get_thread().get_thread_id() == tid)

for pos, threadlinewidget in enumerate(self.threadlist.get_lines()):
if threadlinewidget.get_thread().get_thread_id() == tid:
Expand Down