diff --git a/veilid-cli/src/cached_text_view.rs b/veilid-cli/src/cached_text_view.rs index 7f9b6d6c..d6137c88 100644 --- a/veilid-cli/src/cached_text_view.rs +++ b/veilid-cli/src/cached_text_view.rs @@ -118,6 +118,9 @@ impl TextContent { /// Remove lines from the beginning until we have no more than 'count' from the end pub fn resize_back(&self, count: usize) { + if self.get_content().len() <= count { + return; + } self.with_content(|c| { while c.len() > count { c.remove(0); @@ -127,13 +130,15 @@ impl TextContent { /// Remove lines from the end until we have no more than 'count' from the beginning pub fn resize_front(&self, count: usize) { + if self.get_content().len() <= count { + return; + } self.with_content(|c| { while c.len() > count { c.remove(c.len() - 1); } }) } - /// Returns a reference to the content. /// /// This locks the data while the returned value is alive, diff --git a/veilid-cli/src/ui.rs b/veilid-cli/src/ui.rs index 10685c97..f54d5f5a 100644 --- a/veilid-cli/src/ui.rs +++ b/veilid-cli/src/ui.rs @@ -239,9 +239,9 @@ impl UI { fn node_events_view(s: &mut Cursive) -> ViewRef { s.find_name("node-events-view").unwrap() } - // fn node_events_scroll_view(s: &mut Cursive) -> ViewRef> { - // s.find_name("node-events-scroll-view").unwrap() - // } + fn node_events_scroll_view(s: &mut Cursive) -> ViewRef>> { + s.find_name("node-events-scroll-view").unwrap() + } fn command_line(s: &mut Cursive) -> ViewRef { s.find_name("command-line").unwrap() } @@ -894,6 +894,12 @@ impl UI { .with_name("node-events-view") .scrollable() .scroll_strategy(cursive::view::ScrollStrategy::StickToBottom) + .on_scroll(|s, _r| { + let mut sv = UI::node_events_scroll_view(s); + if sv.is_at_bottom() { + sv.set_scroll_strategy(cursive::view::ScrollStrategy::StickToBottom); + } + }) .with_name("node-events-scroll-view"), ) .title_position(HAlign::Left) diff --git a/veilid-core/src/veilid_api/debug.rs b/veilid-core/src/veilid_api/debug.rs index 2d0ece6e..901fe9b6 100644 --- a/veilid-core/src/veilid_api/debug.rs +++ b/veilid-core/src/veilid_api/debug.rs @@ -1645,7 +1645,9 @@ impl VeilidAPI { } Ok(v) => v, }; - + if ts.as_u64() == 0 { + return Ok("Failed to watch value".to_owned()); + } Ok(format!("Success: expiration={:?}", debug_ts(ts.as_u64()))) }