From 6b4ce98f20b3cfc14f1c955565a8acd9abcc16a2 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 17 Aug 2026 07:20:29 +0900 Subject: refactor(preg): report unmatched groups as null in the vec-shaped preg_* preg_match_all() and preg_match_all_set_order() were the last preg_* functions handing back a bare Vec, where a group that did not participate is indistinguishable from one that captured "". Hand back Option as the map-shaped functions already do; php_match_row(), the last of the truncate-then-pad helpers, goes with them. preg_split_delim_capture() keeps its Vec. preg_split() accepts no PREG_UNMATCHED_AS_NULL, so there is no null form to move it to, and its result interleaves split segments -- which can never be absent -- with the captured delimiters. Co-Authored-By: Claude Opus 5 (1M context) --- .../src/completion/completion_input.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'crates/shirabe-symfony-console/src/completion/completion_input.rs') diff --git a/crates/shirabe-symfony-console/src/completion/completion_input.rs b/crates/shirabe-symfony-console/src/completion/completion_input.rs index 2f146a39..aafa7c8a 100644 --- a/crates/shirabe-symfony-console/src/completion/completion_input.rs +++ b/crates/shirabe-symfony-console/src/completion/completion_input.rs @@ -34,7 +34,17 @@ impl CompletionInput { input_str, ); - Self::from_tokens(tokens[0].clone(), current_index) + Self::from_tokens( + tokens[0] + .iter() + .map(|token| { + token + .clone() + .expect("group 0 participates whenever the pattern matches") + }) + .collect(), + current_index, + ) } /// Create an input based on an COMP_WORDS token list. -- cgit v1.3.1-4-g156e