Skip to content

Commit 66896f8

Browse files
authored
Capture initial Enter key release (#59)
1 parent 76f6f57 commit 66896f8

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

crates/cargo-gpu/src/spirv_cli.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,19 @@ impl SpirvCli {
209209
}
210210
log::debug!("asking for consent to install the required toolchain");
211211
crossterm::terminal::enable_raw_mode().context("enabling raw mode")?;
212-
crate::user_output!("{prompt} [y/n]: ");
213-
let input = crossterm::event::read().context("reading crossterm event")?;
212+
crate::user_output!("{prompt} [y/n]: \n");
213+
let mut input = crossterm::event::read().context("reading crossterm event")?;
214+
215+
if let crossterm::event::Event::Key(crossterm::event::KeyEvent {
216+
code: crossterm::event::KeyCode::Enter,
217+
kind: crossterm::event::KeyEventKind::Release,
218+
..
219+
}) = input
220+
{
221+
// In Powershell, programs will potentially observe the Enter key release after they started
222+
// (see crossterm#124). If that happens, re-read the input.
223+
input = crossterm::event::read().context("re-reading crossterm event")?;
224+
}
214225
crossterm::terminal::disable_raw_mode().context("disabling raw mode")?;
215226

216227
if let crossterm::event::Event::Key(crossterm::event::KeyEvent {

0 commit comments

Comments
 (0)