Skip to content

Commit

Permalink
Optimize page completions
Browse files Browse the repository at this point in the history
  • Loading branch information
gwenn committed Jul 22, 2018
1 parent 1241c31 commit d54d044
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,19 @@ fn complete_line<R: RawReader, C: Completer>(
}
Ok(Some(cmd))
} else if CompletionType::List == config.completion_type() {
// beep if ambiguous
if candidates.len() > 1 {
try!(s.out.beep());
}
if let Some(lcp) = longest_common_prefix(&candidates) {
// if we can extend the item, extend it and return to main loop
// if we can extend the item, extend it
if lcp.len() > s.line.pos() - start {
completer.update(&mut s.line, start, lcp);
try!(s.refresh_line());
return Ok(None);
}
}
// beep if ambiguous
if candidates.len() > 1 {
try!(s.out.beep());
} else {
return Ok(None);
}
// we can't complete any further, wait for second tab
let mut cmd = try!(s.next_cmd(input_state, rdr, true));
// if any character other than tab, pass it to the main loop
Expand Down

0 comments on commit d54d044

Please sign in to comment.