Skip to content

Commit a28e006

Browse files
committed
added back the triple backtick validation
1 parent d497782 commit a28e006

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

crates/chat-cli/src/cli/chat/prompt.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,17 @@ impl Validator for MultiLineValidator {
402402
fn validate(&self, os: &mut ValidationContext<'_>) -> rustyline::Result<ValidationResult> {
403403
let input = os.input();
404404

405+
// Check for code block markers
406+
if input.contains("```") {
407+
// Count the number of ``` occurrences
408+
let triple_backtick_count = input.matches("```").count();
409+
410+
// If we have an odd number of ```, we're in an incomplete code block
411+
if triple_backtick_count % 2 == 1 {
412+
return Ok(ValidationResult::Incomplete);
413+
}
414+
}
415+
405416
// Check for backslash continuation
406417
if input.ends_with('\\') {
407418
return Ok(ValidationResult::Incomplete);

0 commit comments

Comments
 (0)