mirror of
https://github.com/powerline/powerline.git
synced 2025-07-25 06:46:33 +02:00
Fix behavior with run_once: .update() was called too much times
This commit is contained in:
parent
a65a27e673
commit
e6dd40bff0
@ -72,7 +72,9 @@ class ThreadedSegment(object):
|
|||||||
self.set_interval(interval)
|
self.set_interval(interval)
|
||||||
# Without this we will not have to wait long until receiving bug “I
|
# Without this we will not have to wait long until receiving bug “I
|
||||||
# opened vim, but branch information is only shown after I move cursor”.
|
# opened vim, but branch information is only shown after I move cursor”.
|
||||||
if self.update_first:
|
#
|
||||||
|
# If running once .update() is called in __call__.
|
||||||
|
if self.update_first and not self.run_once:
|
||||||
self.update_first = False
|
self.update_first = False
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
@ -115,7 +117,7 @@ class KwThreadedSegment(ThreadedSegment):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
# self.update_missing has the same reasoning as self.update_first in
|
# self.update_missing has the same reasoning as self.update_first in
|
||||||
# parent class
|
# parent class
|
||||||
update_state = self.compute_state(key) if self.update_missing else None
|
update_state = self.compute_state(key) if self.update_missing or self.run_once else None
|
||||||
# No locks: render method is already running with write_lock acquired.
|
# No locks: render method is already running with write_lock acquired.
|
||||||
self.queries[key] = (monotonic(), update_state)
|
self.queries[key] = (monotonic(), update_state)
|
||||||
return self.render_one(update_state, **kwargs)
|
return self.render_one(update_state, **kwargs)
|
||||||
@ -138,7 +140,7 @@ class KwThreadedSegment(ThreadedSegment):
|
|||||||
self.set_interval(interval)
|
self.set_interval(interval)
|
||||||
|
|
||||||
key = self.key(**kwargs)
|
key = self.key(**kwargs)
|
||||||
if key not in self.queries:
|
if not self.run_once and key not in self.queries:
|
||||||
self.queries[key] = (monotonic(), self.compute_state(key) if self.update_missing else None)
|
self.queries[key] = (monotonic(), self.compute_state(key) if self.update_missing else None)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user