From 8acbdd7ad4e4c43f54450d4005118920d3475dd7 Mon Sep 17 00:00:00 2001 From: "Dhanji R. Prasanna" Date: Tue, 20 Jan 2026 11:44:29 +0530 Subject: [PATCH] Add tests for bare quote and non-path quoted text edge cases Verifies that tab completion correctly ignores: - Bare quotes: " - no path prefix, no completion - Quoted non-paths: "hello world - not a path, no completion - Quoted text without path prefix: "foo - no completion Also fixes test placement (moved tests inside mod tests block) --- crates/g3-cli/src/completion.rs | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/crates/g3-cli/src/completion.rs b/crates/g3-cli/src/completion.rs index 0c96ed7..ef14e2a 100644 --- a/crates/g3-cli/src/completion.rs +++ b/crates/g3-cli/src/completion.rs @@ -414,4 +414,47 @@ mod tests { Err(e) => println!("Error: {:?}", e), } } + + #[test] + fn test_no_completion_for_bare_quote() { + use rustyline::completion::Completer; + use rustyline::Context; + + let helper = G3Helper::new(); + let history = rustyline::history::DefaultHistory::new(); + let ctx = Context::new(&history); + + // Just a quote with no path prefix - should NOT trigger completion + let line = "edit \""; + let pos = line.len(); + let (start, completions) = helper.complete(line, pos, &ctx).unwrap(); + println!("Line: '{}', start: {}, completions: {}", line, start, completions.len()); + + // Should return no completions since "" is not a path prefix + assert_eq!(completions.len(), 0, "Bare quote should not trigger path completion"); + } + + #[test] + fn test_no_completion_for_random_text_in_quotes() { + use rustyline::completion::Completer; + use rustyline::Context; + + let helper = G3Helper::new(); + let history = rustyline::history::DefaultHistory::new(); + let ctx = Context::new(&history); + + // Random text in quotes - should NOT trigger completion + let line = "edit \"hello world"; + let pos = line.len(); + let (start, completions) = helper.complete(line, pos, &ctx).unwrap(); + println!("Line: '{}', start: {}, completions: {}", line, start, completions.len()); + assert_eq!(completions.len(), 0, "Random quoted text should not trigger path completion"); + + // Just "foo - no path prefix + let line = "edit \"foo"; + let pos = line.len(); + let (start, completions) = helper.complete(line, pos, &ctx).unwrap(); + println!("Line: '{}', start: {}, completions: {}", line, start, completions.len()); + assert_eq!(completions.len(), 0, "Quoted non-path should not trigger completion"); + } }