Skip to content

Commit 0a03d00

Browse files
adityamukhoclaude
andcommitted
fix: prevent duplicate prompts and delayed output when pasting multi-command blocks
Blank lines and comments between pasted commands caused the loop to re-print the prompt on each iteration. A prompt_needed flag ensures it fires once per command, not once per skipped line. Also flush stdout immediately after printing each result so output is not held in the buffer until the next prompt flush. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 343401a commit 0a03d00

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/repl.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,14 @@ impl<'a> Repl<'a> {
6060

6161
let mut command_buffer = String::new();
6262
let mut is_multiline = false;
63+
// Only print the prompt once per command, not once per blank/comment line.
64+
let mut prompt_needed = true;
6365

6466
loop {
65-
if interactive && !is_multiline {
67+
if interactive && !is_multiline && prompt_needed {
6668
print!("minigraf> ");
6769
io::stdout().flush().ok();
70+
prompt_needed = false;
6871
}
6972

7073
let mut input = String::new();
@@ -106,8 +109,10 @@ impl<'a> Repl<'a> {
106109

107110
command_buffer.clear();
108111
is_multiline = false;
112+
prompt_needed = true;
109113
if interactive {
110114
println!();
115+
io::stdout().flush().ok();
111116
}
112117
} else {
113118
is_multiline = true;

0 commit comments

Comments
 (0)