diff options
| author | sigoden <sigoden@gmail.com> | 2023-03-08 21:34:20 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-08 21:34:20 +0800 |
| commit | 9d32837669f0aef54a67fceee3bf7211b31ed98f (patch) | |
| tree | a68109784a57ac02d26b1d9c36338d3a93eb94e6 /src/repl/handler.rs | |
| parent | 56483e04f0b8c74e9f7f809e1a0035ca876e35f6 (diff) | |
| download | aichat-9d32837669f0aef54a67fceee3bf7211b31ed98f.tar.gz | |
chore: optimize newline again (#43)
* chore: optimize newline again
command mode: should no extra newline
chat mode: should have one newline
* fix windows newline
* fix macos newline
Diffstat (limited to 'src/repl/handler.rs')
| -rw-r--r-- | src/repl/handler.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/repl/handler.rs b/src/repl/handler.rs index 5855208..22d8fd0 100644 --- a/src/repl/handler.rs +++ b/src/repl/handler.rs @@ -97,14 +97,20 @@ pub struct ReplyStreamHandler { sender: Option<Sender<ReplyStreamEvent>>, buffer: String, abort: SharedAbortSignal, + repl: bool, } impl ReplyStreamHandler { - pub fn new(sender: Option<Sender<ReplyStreamEvent>>, abort: SharedAbortSignal) -> Self { + pub fn new( + sender: Option<Sender<ReplyStreamEvent>>, + repl: bool, + abort: SharedAbortSignal, + ) -> Self { Self { sender, abort, buffer: String::new(), + repl, } } @@ -132,6 +138,12 @@ impl ReplyStreamHandler { if !self.buffer.ends_with('\n') { print_now!("\n") } + if self.repl { + print_now!("\n"); + if cfg!(macos) { + print_now!("\n") + } + } } } Ok(()) |
