console-rs / console-rs/console
Term::read_line_initial_text() inconsistent with Term::read_line() regarding terminating newline
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.2k
- Forks
- 144
- Avg merge
- 8h 24m
- Merged PRs (30d)
- 4
Description
Term::read_line() allows the delimiting newline to be printed to the terminal, even though it is omitted from the returned String. This is the same as the documented behaviour of BufRead::read_line(), which Term::read_line() ends up calling.
The implementation of Term::read_line_initial_text() is not consistent with this. In this case, the newline is not printed to the terminal.
use console::Term;
fn main() {
let term = Term::stderr();
println!("Enter ten lines. The final five will have initial text");
for _ in 1..6 {
term.read_line().unwrap();
}
for _ in 6..11 {
term.read_line_initial_text("Inital text ").unwrap();
}
}
After I run the above and enter the numbers 1 to 10, my terminal looks like this:
Enter ten lines. The final five will have initial text
1
2
3
4
5
Inital text 6Inital text 7Inital text 8Inital text 9Inital text 10$
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the implementations of Term::read_line() and Term::read_line_initial_text(), then reproduce the example from the issue with Term::stderr(). Compare how each method handles the terminating newline; done means lines entered with initial text are separated by newlines like the regular read_line() output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100