Cursor Keys get stuck in Normal Mode in Git for Windows; DECCKM has no effect #9194

Open
opened 2026-01-31 01:48:26 +00:00 by claunia · 0 comments
Owner

Originally created by @KalleOlaviNiemitalo on GitHub (Jun 22, 2020).

Environment

Windows build number: Microsoft Windows NT 10.0.19041.0
Windows Terminal version (if applicable): Windows Terminal Preview 1.1.1671.0
Git for Windows 2.27.0

Profile:

{
    "guid": "{dc9f4186-52a8-4b9f-a659-0c438c764b58}",
    "commandline": "\"%ProgramFiles%\\Git\\bin\\bash.exe\" -i -l",
    "name": "Git Bash",
    "icon": "%ProgramFiles%\\Git\\mingw64\\share\\git\\git-for-windows.ico",
    "hidden": false
}

TERM=xterm-256color by default.

MSYS=enable_pcon because pseudoconsoles were enabled when Git for Windows was installed.

Steps to reproduce

  1. Delete the Ctrl+C and Ctrl+V key bindings in settings.json.
  2. Either start the profile shown above, or start the Command Prompt profile and run "C:\Program Files\Git\bin\bash.exe" in CMD.
  3. Run less /etc/package-versions.txt in Bash.
  4. Press the Down arrow key and note that the file scrolls OK.
  5. Press q to exit less.
  6. Run cat in Bash.
  7. Press Ctrl+C to terminate cat.
  8. Run less /etc/package-versions.txt in Bash.
  9. Press the Down arrow key.

Expected behavior

The file scrolls again, like before.

Actual behavior

The file does not scroll. Instead, ESC[ briefly flashes on the bottom line.

If you then open a new tab, arrow keys work OK in that tab.

Cause

The ENABLE_VIRTUAL_TERMINAL_INPUT mode is left disabled when cat is terminated. This causes ReadConsoleInputW to return virtual keys such as VK_DOWN, rather than console virtual terminal sequences. MSYS then translates the VK_DOWN to the normal-mode sequence ESC [ B, but less expects the application-mode sequence ESC O B.

Originally created by @KalleOlaviNiemitalo on GitHub (Jun 22, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: Microsoft Windows NT 10.0.19041.0 Windows Terminal version (if applicable): Windows Terminal Preview 1.1.1671.0 Git for Windows 2.27.0 ``` Profile: ```json { "guid": "{dc9f4186-52a8-4b9f-a659-0c438c764b58}", "commandline": "\"%ProgramFiles%\\Git\\bin\\bash.exe\" -i -l", "name": "Git Bash", "icon": "%ProgramFiles%\\Git\\mingw64\\share\\git\\git-for-windows.ico", "hidden": false } ``` `TERM=xterm-256color` by default. `MSYS=enable_pcon` because pseudoconsoles were enabled when Git for Windows was installed. # Steps to reproduce 1. Delete the Ctrl+C and Ctrl+V key bindings in settings.json. 2. Either start the profile shown above, or start the Command Prompt profile and run `"C:\Program Files\Git\bin\bash.exe"` in CMD. 3. Run `less /etc/package-versions.txt` in Bash. 4. Press the Down arrow key and note that the file scrolls OK. 5. Press `q` to exit `less`. 6. Run `cat` in Bash. 7. Press Ctrl+C to terminate `cat`. 8. Run `less /etc/package-versions.txt` in Bash. 9. Press the Down arrow key. # Expected behavior The file scrolls again, like before. # Actual behavior The file does not scroll. Instead, `ESC[` briefly flashes on the bottom line. If you then open a new tab, arrow keys work OK in that tab. # Cause The `ENABLE_VIRTUAL_TERMINAL_INPUT` mode is left disabled when `cat` is terminated. This causes [ReadConsoleInputW](https://docs.microsoft.com/windows/console/readconsoleinput) to return virtual keys such as `VK_DOWN`, rather than [console virtual terminal sequences](https://docs.microsoft.com/windows/console/console-virtual-terminal-sequences#input-sequences). MSYS then translates the `VK_DOWN` to the normal-mode sequence `ESC [ B`, but `less` expects the application-mode sequence `ESC O B`.
claunia added the Needs-TriageNeeds-Tag-Fix labels 2026-01-31 01:48:26 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#9194