summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Tay <sam.chong.tay@gmail.com>2020-06-16 12:43:18 -0700
committerSam Tay <sam.chong.tay@gmail.com>2020-06-16 12:43:18 -0700
commit00990e57824bd12bd3f7fc69aa51652b33fdb60a (patch)
tree340b0e70737aba3fe1f2a312abeb8022652d59bc
parentbd3e479aaf76ea6ec94a680123b393eca971387f (diff)
Remove timeout on vim "gg" binding
Turns out vim doesn't even do that, so why bother
-rw-r--r--src/tui/views.rs18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/tui/views.rs b/src/tui/views.rs
index 6558d25..b49d5ac 100644
--- a/src/tui/views.rs
+++ b/src/tui/views.rs
@@ -10,7 +10,6 @@ use cursive::{Cursive, Vec2, XY};
use std::fmt;
use std::fmt::Display;
use std::rc::Rc;
-use std::time;
use super::markdown;
use crate::error::Result;
@@ -20,10 +19,6 @@ pub const NAME_ANSWER_LIST: &str = "answer_list";
pub const NAME_QUESTION_VIEW: &str = "question_view";
pub const NAME_ANSWER_VIEW: &str = "answer_view";
pub const NAME_FULL_LAYOUT: &str = "full_layout";
-// This is in std lib but currently unstable
-const SECOND: time::Duration = time::Duration::from_secs(1);
-
-// TODO might need resizable wrappers in types
pub enum Name {
QuestionList,
@@ -516,7 +511,7 @@ impl LayoutView {
/// having an inner EditView. If more nuance is needed later, then it will keep
/// track of a `Mode = Insert | Command`
pub struct VimBindingsView<T: View> {
- last_event: Option<(Event, time::Instant)>, // TODO add time and check elapsed
+ last_event: Option<Event>,
view: T,
}
@@ -527,14 +522,11 @@ impl<T: View> ViewWrapper for VimBindingsView<T> {
// TODO add more
match event {
Event::Char('g') => {
- let now = time::Instant::now();
- match self.last_event {
- Some((Event::Char('g'), then)) if now.duration_since(then) < SECOND => {
- self.last_event = None;
- return self.view.on_event(Event::Key(Key::Home));
- }
- _ => self.last_event = Some((Event::Char('g'), now)),
+ if let Some(Event::Char('g')) = self.last_event {
+ self.last_event = None;
+ return self.view.on_event(Event::Key(Key::Home));
}
+ self.last_event = Some(Event::Char('g'));
}
_ => self.last_event = None,
}