Skip to content

Commit

Permalink
Update read_line behaviour to read_line_initial_text (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
thibmeu committed Jan 9, 2024
1 parent 072f9f7 commit 50ccfcd
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,7 @@ impl Term {
/// This does not include the trailing newline. If the terminal is not
/// user attended the return value will always be an empty string.
pub fn read_line(&self) -> io::Result<String> {
if !self.is_tty {
return Ok("".into());
}
let mut rv = String::new();
io::stdin().read_line(&mut rv)?;
let len = rv.trim_end_matches(&['\r', '\n'][..]).len();
rv.truncate(len);
Ok(rv)
self.read_line_initial_text("")
}

/// Read one line of input with initial text.
Expand Down

0 comments on commit 50ccfcd

Please sign in to comment.