Skip to content

Commit 5a28772

Browse files
committed
fix(install): filter KeyEventKind on Windows for arrow key navigation
On Windows, crossterm emits both Press and Release events for each key press. Without filtering for Press-only, arrow keys in the `vp i` package manager prompt were processed twice per press (move then move back), making them appear non-functional. Closes #1361
1 parent 18f9f50 commit 5a28772

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

crates/vite_install/src/package_manager.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::{
88

99
use crossterm::{
1010
cursor,
11-
event::{self, Event, KeyCode, KeyEvent},
11+
event::{self, Event, KeyCode, KeyEvent, KeyEventKind},
1212
execute,
1313
style::{Color, Print, ResetColor, SetForegroundColor},
1414
terminal,
@@ -827,7 +827,10 @@ fn interactive_package_manager_menu() -> Result<PackageManagerType, Error> {
827827
}
828828

829829
// Read keyboard input
830-
if let Event::Key(KeyEvent { code, modifiers, .. }) = event::read()? {
830+
if let Event::Key(KeyEvent { code, modifiers, kind, .. }) = event::read()? {
831+
if kind != KeyEventKind::Press {
832+
continue;
833+
}
831834
match code {
832835
// Handle Ctrl+C for exit
833836
KeyCode::Char('c') if modifiers.contains(event::KeyModifiers::CONTROL) => {

0 commit comments

Comments
 (0)