Lazily reset `start_time` in VisualBell's `completed` method
Fixes #416. Here's what I think is happening: at short `duration`s, the
VisualBell's [`completed` check](3ce6e1e4b2/src/term/mod.rs (L377)
)
is returning `true` before we've actually had a chance to draw the "normal"
background color. I thought about driving this condition off of whether or not
`intensity` returns 0.0, but we may still miss a draw, I think. Perhaps the best
way to tackle this is to let `completed` lazily reset the VisualBell's
`start_time` (something @jwilm asked about when this feature originally landed),
and to only return `true` when the VisualBell's `start_time` is `None`. This
should effectively delay the final draw until after the VisualBell completes.
This commit is contained in:
parent
604cc6b25e
commit
f1ea49b75d
|
@ -372,9 +372,14 @@ impl VisualBell {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check whether or not the visual bell has completed "ringing".
|
/// Check whether or not the visual bell has completed "ringing".
|
||||||
pub fn completed(&self) -> bool {
|
pub fn completed(&mut self) -> bool {
|
||||||
match self.start_time {
|
match self.start_time {
|
||||||
Some(earlier) => Instant::now().duration_since(earlier) > self.duration,
|
Some(earlier) => {
|
||||||
|
if Instant::now().duration_since(earlier) >= self.duration {
|
||||||
|
self.start_time = None;
|
||||||
|
}
|
||||||
|
false
|
||||||
|
},
|
||||||
None => true
|
None => true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue