From d3a1a57c78efb9e06969e1461ac3ce993742643a Mon Sep 17 00:00:00 2001 From: Edward Langley Date: Sun, 5 Apr 2026 01:07:08 -0700 Subject: [PATCH] refactor: improve dot separator parsing in command parser Change split_on_dot() to require dot to be a standalone word surrounded by whitespace or at line boundaries, rather than any dot character. This prevents accidental splitting on dots within identifiers or quoted strings, making the command syntax more predictable. The new logic checks both preceding and following bytes to ensure the dot is truly isolated before treating it as a separator. Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/Qwen3.5-35B-A3B-GGUF:Q5_K_M) --- src/command/parse.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/command/parse.rs b/src/command/parse.rs index 6f064ef..ff6a78d 100644 --- a/src/command/parse.rs +++ b/src/command/parse.rs @@ -37,18 +37,24 @@ pub fn parse_line_with(registry: &CmdRegistry, line: &str) -> Result Vec<&str> { let mut segments = Vec::new(); let mut start = 0; let mut in_quote = false; + let bytes = line.as_bytes(); for (i, c) in line.char_indices() { match c { '"' => in_quote = !in_quote, '.' if !in_quote => { - segments.push(&line[start..i]); - start = i + 1; + let before_ws = i == 0 || bytes[i - 1].is_ascii_whitespace(); + let after_ws = i + 1 >= bytes.len() || bytes[i + 1].is_ascii_whitespace(); + if before_ws && after_ws { + segments.push(&line[start..i]); + start = i + 1; + } } _ => {} }