File tree Expand file tree Collapse file tree
vite_task_bin/tests/e2e_snapshots/fixtures/task-select Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -95,6 +95,16 @@ fn non_interactive(
9595 before_render ( & mut filtered, query. unwrap_or_default ( ) ) ;
9696 let len = filtered. len ( ) ;
9797
98+ // When there are no matching items, just print the header (if any) and
99+ // return early — avoids showing a redundant "No matching tasks." line
100+ // after a "not found" header.
101+ if filtered. is_empty ( ) {
102+ if let Some ( h) = header {
103+ writeln ! ( writer, "{h}" ) ?;
104+ }
105+ return Ok ( ( ) ) ;
106+ }
107+
98108 render_items (
99109 writer,
100110 & RenderParams {
Original file line number Diff line number Diff line change @@ -378,12 +378,20 @@ impl<'a> Session<'a> {
378378 } )
379379 . collect ( ) ;
380380
381- // Build header: interactive says "not found.", non-interactive "did you mean:" suffix
381+ // Build header: interactive says "not found.", non-interactive adds
382+ // "Did you mean:" suffix only when there are fuzzy matches to show.
382383 let header = not_found_name. map ( |name| {
383384 if is_interactive {
384385 vite_str:: format!( "Task \" {name}\" not found." )
385386 } else {
386- vite_str:: format!( "Task \" {name}\" not found. Did you mean:" )
387+ let labels: Vec < & str > =
388+ select_items. iter ( ) . map ( |item| item. label . as_str ( ) ) . collect ( ) ;
389+ let has_suggestions = !vite_select:: fuzzy_match ( name, & labels) . is_empty ( ) ;
390+ if has_suggestions {
391+ vite_str:: format!( "Task \" {name}\" not found. Did you mean:" )
392+ } else {
393+ vite_str:: format!( "Task \" {name}\" not found." )
394+ }
387395 }
388396 } ) ;
389397
Original file line number Diff line number Diff line change @@ -12,6 +12,13 @@ steps = [
1212 " echo '' | vp run buid" ,
1313]
1414
15+ # Non-interactive: typo with no fuzzy matches hides "did you mean"
16+ [[e2e ]]
17+ name = " non-interactive no suggestions"
18+ steps = [
19+ " echo '' | vp run zzzzz" ,
20+ ]
21+
1522# Non-interactive: typo with -r flag errors (not cwd_only)
1623[[e2e ]]
1724name = " non-interactive recursive typo errors"
Original file line number Diff line number Diff line change 1+ -- -
2+ source : crates / vite_task_bin / tests / e2e_snapshots / main .rs
3+ expression : e2e_outputs
4+ -- -
5+ [1 ]> echo ' ' | vp run zzzzz
6+ Task " zzzzz" not found .
You can’t perform that action at this time.
0 commit comments