Skip to content

Commit f2d9589

Browse files
committed
Ensure the first character is a double quotes
1 parent 3027e76 commit f2d9589

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/bin/main.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,23 @@ fn get_input() -> String {
2020
noecho();
2121

2222
/* Prompt for a character. */
23-
printw("Please enter your diff (ENTER / ESC once done):\n");
23+
printw("Please enter your diff, must start with double quotes (ENTER / ESC once done):\n");
2424
let mut input = String::new();
25+
let mut started = false;
2526
loop {
2627
let ch = getch();
27-
// Return if ENTER or ESC
28-
if ch == 10 || ch == 27 {
29-
refresh();
30-
break;
31-
} else {
32-
let c = char::from_u32(ch as u32).expect("Invalid char");
33-
printw(&format!("{}", c));
34-
input.push(c);
28+
match ch {
29+
10 | 27 => break, // Return if ENTER or ESC
30+
_ => {
31+
let c = char::from_u32(ch as u32).expect("Invalid char");
32+
if started || c == '"' {
33+
printw(&format!("{}", c));
34+
input.push(c);
35+
if !started {
36+
started = true;
37+
}
38+
}
39+
}
3540
}
3641
refresh();
3742
}

0 commit comments

Comments
 (0)