diff --git a/src/completion.rs b/src/completion.rs index ad0a93f0b434f8c062bb8531f3a99bc8bd336080..16448c524298d5ce9b1f211753ab17c703769d43 100644 --- a/src/completion.rs +++ b/src/completion.rs @@ -171,7 +171,7 @@ pub fn longest_common_prefix(candidates: &[String]) -> Option<&str> { let b1 = candidates[i].as_bytes(); let b2 = candidates[i + 1].as_bytes(); if b1.len() <= longest_common_prefix || b2.len() <= longest_common_prefix || - b1[i] != b2[i] { + b1[longest_common_prefix] != b2[longest_common_prefix] { break 'o; } } @@ -227,5 +227,9 @@ mod tests { let lcp = super::longest_common_prefix(&candidates); assert!(lcp.is_none()); } + + let candidates = vec![String::from("fée"), String::from("fête")]; + let lcp = super::longest_common_prefix(&candidates); + assert_eq!(Some("f"), lcp); } } diff --git a/src/lib.rs b/src/lib.rs index ebcabdd4ec37f88d929f10e6442c7377f93c1e03..b115ed9bfca6b7cc3739c3784b8ac1f67087aa6c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -600,6 +600,13 @@ fn complete_line<R: Read>(rdr: &mut tty::RawReader<R>, return Ok(None); } } + // we can't complete any further, wait for second tab + let key = try!(rdr.next_key(false)); + // if any character other than tab, pass it to the main loop + if key != KeyPress::Tab { + return Ok(Some(key)) + } + // we got a second tab, maybe show list of possible completions // TODO ... Ok(None) } else {