walker: keep optional trailing flags completable after --
Typing `--` to start an optional trailing flag (`--create-fk` on `add 1:n relationship`, `--cascade` on `drop column`, `--force-conversion` / `--dont-convert` on `change column`) made completion go empty: the trailing `--` turns the parse into a trailing-junk Mismatch, and the Mismatch arm of the completion expected-set resolution returned only `[EndOfInput]` — the skipped optional-flag expectations, carried in `tail_expected`, were dropped. completion_probe and expected_at_input now merge `tail_expected` into a Mismatch's expected set. `tail_expected` is empty for a genuine mid-command mismatch, so this only adds the outer shape's skipped trailing optionals — exactly the continuations the trailing `--` is starting to type. This also resolves the "wrong usage hint" symptom: with `--create-fk` offered as a candidate, the hint panel shows candidates instead of falling through to the parse-error usage block. Audit outcome (the requested scan): usage_key_for_input was verified correct for every multi-form command — add / drop / show, including the digit-led `add 1:n relationship` form — and is now regression-locked. The flag-completion fix covers the whole optional-trailing-flag class. 6 tests (3 flag-completion, 3 usage-key). 1131 passing.
This commit is contained in:
@@ -909,6 +909,48 @@ mod tests {
|
||||
assert!(cs.contains(&"--all-rows".to_string()), "got {cs:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn typed_dashes_still_offer_an_optional_trailing_flag() {
|
||||
// Regression: `add 1:n relationship … [--create-fk]` —
|
||||
// at a trailing space the flag is offered, but once the
|
||||
// user typed `--` the trailing-junk Mismatch dropped the
|
||||
// skipped optional's expectation and completion went
|
||||
// empty. Both positions must offer `--create-fk`.
|
||||
let at_space = cands("add 1:n relationship from X.a to Y.b ", 37);
|
||||
assert!(
|
||||
at_space.contains(&"--create-fk".to_string()),
|
||||
"trailing space should offer --create-fk, got {at_space:?}",
|
||||
);
|
||||
let at_dashes = cands("add 1:n relationship from X.a to Y.b --", 39);
|
||||
assert!(
|
||||
at_dashes.contains(&"--create-fk".to_string()),
|
||||
"typed `--` should still offer --create-fk, got {at_dashes:?}",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn typed_dashes_offer_the_optional_cascade_flag_on_drop_column() {
|
||||
// The same optional-flag class: `drop column … [--cascade]`.
|
||||
let at_dashes = cands("drop column from table T: c --", 30);
|
||||
assert!(
|
||||
at_dashes.contains(&"--cascade".to_string()),
|
||||
"typed `--` should offer --cascade, got {at_dashes:?}",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn typed_dashes_offer_the_change_column_conversion_flags() {
|
||||
// `change column … [--force-conversion | --dont-convert]`
|
||||
// — the flags sit in a `Repeated { min: 0 }`; the same
|
||||
// trailing-junk-Mismatch fix must surface them.
|
||||
let at_dashes = cands("change column T: c (int) --", 27);
|
||||
assert!(
|
||||
at_dashes.contains(&"--force-conversion".to_string())
|
||||
&& at_dashes.contains(&"--dont-convert".to_string()),
|
||||
"typed `--` should offer both conversion flags, got {at_dashes:?}",
|
||||
);
|
||||
}
|
||||
|
||||
// ---- App-lifecycle command completion (round-5 fold-in) ----
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user