@@ -81,6 +81,7 @@ impl<'a> ParserError<Partial<&'a str>> for Error<'a> {
8181
8282#[ derive( Debug ) ]
8383pub struct ParseState {
84+ pub is_first_line : bool ,
8485 pub terminal_width : Option < usize > ,
8586 pub markdown_disabled : Option < bool > ,
8687 pub column : usize ,
@@ -96,6 +97,7 @@ pub struct ParseState {
9697impl ParseState {
9798 pub fn new ( terminal_width : Option < usize > , markdown_disabled : Option < bool > ) -> Self {
9899 Self {
100+ is_first_line : true ,
99101 terminal_width,
100102 markdown_disabled,
101103 column : 0 ,
@@ -198,8 +200,17 @@ fn text<'a, 'b>(
198200) -> impl FnMut ( & mut Partial < & ' a str > ) -> PResult < ( ) , Error < ' a > > + ' b {
199201 move |i| {
200202 let content = take_while ( 1 .., |t| AsChar :: is_alphanum ( t) || "+,.!?\" " . contains ( t) ) . parse_next ( i) ?;
201- queue_newline_or_advance ( & mut o, state, content. width ( ) ) ?;
203+ if state. is_first_line {
204+ state. is_first_line = false ;
205+ // The extra space here is reserved for the prompt pointer ("> ").
206+ // Essentially we want the input to wrap as if the prompt pointer is a part of it
207+ // but only display what is received.
208+ queue_newline_or_advance ( & mut o, state, content. width ( ) + 2 ) ?;
209+ } else {
210+ queue_newline_or_advance ( & mut o, state, content. width ( ) ) ?;
211+ }
202212 queue ( & mut o, style:: Print ( content) ) ?;
213+
203214 Ok ( ( ) )
204215 }
205216}
0 commit comments