nushell / nushell/reedline

Key events are reported incorrectly

Open
#663 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Rust
Stars
817
Forks
247
Avg merge
4d 14h
Merged PRs (30d)
30

Description

Environment: Windows 11 -> Windows Terminal -> WSL or PowerShell

When imlpement my own EditMode, I stumbled upon an issue: some key events are reported incorrectly.

Basically, I convert the event using ReedlineRawEvent::into() which gives me a crossterm::event::Event value.

If I press Ctrl + Backspace for instance, it will be reported as the w key pressed with the CONTROL modifier.

I tried to debug a little bit by modifying reedline's code and it seems like the event reedline gets from crossterm using crossterm::event::read() already contains the error, it is not caused by a faulty event conversion.

When running the event_listener example in this crate with cargo run --example event_listener, I get the correct code reported.

I tried putting a terminal::enable_raw_mode() just before the event reading, but it did not work. Maybe it needs to be set as soon as the program begins? But would that cause other troubles? I don't enough about terminals to answer this.

But this is a big problem as it makes handling some key combinations impossible. Also pressing Ctrl + Backspace and Ctrl +w return the exact same event, so it's not even possible to work around this problem using a little "hack" hashmap mapping the correct codes.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the event_listener example and compare its terminal setup with reedline's event reading on Windows Terminal under WSL or PowerShell. Reproduce the behavior using cargo run --example event_listener, then investigate whether raw-mode initialization affects the values returned by crossterm::event::read(). Done means Ctrl+Backspace and Ctrl+w produce distinguishable events.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.