voidzero-dev / voidzero-dev/vite-plus

Support wrap-around arrow-key navigation in the vp run / vpr task selector

Aperta
#2,638 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
5.8k
Fork
262
Merge medio
23h 41m
PR unite (30g)
138

Descrizione

### Description

Please support wrap-around arrow-key navigation in the interactive task selector opened by `vp run` / `vpr` without a task name.

Currently, pressing Up on the first task leaves the selection on the first task, and pressing Down on the last task leaves it on the last task. `nr` from `@antfu/ni` already allows moving directly between the first and last entries this way. Matching that behavior would make it quicker to reach tasks near the end of a long list and preserve familiar keyboard navigation when switching from `nr` to `vpr`.

I intend to submit a small implementation PR to the shared `vt_select` component in `voidzero-dev/vite-task` and link it here.

### Suggested solution

- Up on the first selectable task selects the last selectable task.
- Down on the last selectable task selects the first selectable task.
- Wrap within the current search results, not the unfiltered list.
- Skip non-selectable workspace/group headings and scroll the newly selected task into view.
- Empty results and a single result remain safe no-ops.

### Reproduction

Create a directory containing only this `package.json` (no dependency installation is needed):

```json
{
"name": "task-picker-wrap-repro",
"private": true,
"scripts": {
"alpha": "echo alpha",
"beta": "echo beta",
"gamma": "echo gamma"
}
}
```

1. Run `vpr` (or `vp run`) in an interactive terminal.
2. With `alpha` highlighted, press Up. It remains on `alpha`; the requested behavior is to select `gamma`.
3. Press Down until `gamma` is highlighted, then press Down once more. It remains on `gamma`; the requested behavior is to select `alpha`.
4. Press Ctrl+C to exit without running a task.

### Alternative

Repeated arrow presses or typing a search query work, but require more input than wrapping directly at the list boundary.

### Additional context

Reproduced with Vite+ `0.3.1` on Linux x86_64 in a real pseudo-terminal. The comparison command is `@antfu/ni` `30.5.0`.

The boundary checks are in [`State::move_up` and `State::move_down` in `vt_select`](https://github.com/voidzero-dev/vite-task/blob/9a1d32cfc833c46772f29c10958794b1d55e2141/crates/vt_select/src/interactive.rs#L191). This request concerns the `vp run` task selector, not Vite, Vitest, tsdown, Rolldown, or Oxc.

### Validations

- [x] Read the contributing guidelines.
- [x] Searched existing issues and PRs in both `vite-plus` and `vite-task` and did not find the same request.
- [x] This concerns the Vite+ task-selection workflow.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia in crates/vt_select/src/interactive.rs, in State::move_up e State::move_down, quindi esegui la riproduzione fornita con vpr o vp run usando il package.json di esempio. Il lavoro è completato quando Up e Down fanno il giro ciclico tra le attività selezionabili filtrate, saltano le intestazioni, scorrono la nuova selezione nella vista e rimangono sicuri per gli elenchi vuoti o con un solo risultato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
rust
Ambito
cli
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Attiva
Chiarezza
Specificata chiaramente
Idoneità per principianti
76/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.