From e97e64f18aa66bf4a498a33b2e8cd1a481f22bb5 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sun, 27 Oct 2024 11:31:20 +0100 Subject: [PATCH] Test completer impls --- src/completion.rs | 15 ++++++++++++--- src/tty/unix.rs | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/completion.rs b/src/completion.rs index e466d977b..9566f7845 100644 --- a/src/completion.rs +++ b/src/completion.rs @@ -496,6 +496,8 @@ fn find_unclosed_quote(s: &str) -> Option<(usize, Quote)> { #[cfg(test)] mod tests { + use super::{Completer, FilenameCompleter}; + #[test] pub fn extract_word() { let break_chars = super::default_break_chars; @@ -604,16 +606,23 @@ mod tests { #[test] pub fn candidate_impls() { struct StrCmp; - impl super::Completer for StrCmp { + impl Completer for StrCmp { type Candidate = &'static str; } struct RcCmp; - impl super::Completer for RcCmp { + impl Completer for RcCmp { type Candidate = std::rc::Rc; } struct ArcCmp; - impl super::Completer for ArcCmp { + impl Completer for ArcCmp { type Candidate = std::sync::Arc; } } + + #[test] + pub fn completer_impls() { + struct Wrapper(T); + let boxed = Box::new(FilenameCompleter::new()); + let _ = Wrapper(boxed); + } } diff --git a/src/tty/unix.rs b/src/tty/unix.rs index 054b4f118..f08d700b5 100644 --- a/src/tty/unix.rs +++ b/src/tty/unix.rs @@ -1032,7 +1032,7 @@ impl Renderer for PosixRenderer { } // position the cursor within the line if cursor.col > 0 { - write!(self.buffer, "\r\x1b[{}C", cursor.col).unwrap(); + write!(self.buffer, "\r\x1b[{}C", cursor.col)?; } else { self.buffer.push('\r'); }