aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Andrus Roberts <mroberts@twilio.com>2017-02-20 12:22:26 -0800
committerJoe Wilm <jwilm@users.noreply.github.com>2017-02-22 20:57:00 -0800
commitf1ea49b75d81955faebd2e922975bcc58e8634ef (patch)
tree64bb70c75106893f27aef23dfbd273824afcaee0
parent604cc6b25ebbd906b9a132ffc31c16993e553f84 (diff)
downloadalacritty-f1ea49b75d81955faebd2e922975bcc58e8634ef.tar.gz
alacritty-f1ea49b75d81955faebd2e922975bcc58e8634ef.zip
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](https://github.com/jwilm/alacritty/blob/3ce6e1e4b2924b0d432cbb3e62b4bbef88dd38ff/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.
-rw-r--r--src/term/mod.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/term/mod.rs b/src/term/mod.rs
index 2849c6cf..786265ef 100644
--- a/src/term/mod.rs
+++ b/src/term/mod.rs
@@ -372,9 +372,14 @@ impl VisualBell {
}
/// 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 {
- 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
}
}