Skip to content

Keyboard selection (Shift+Arrow keys, etc.) not working in Windows #16245

@dannymcgee

Description

@dannymcgee

Description

Keyboard-based text selection does not work as expected in Windows. This seems to affect all terminals/shells.

  • When using Shift+Left/Right arrows, only two characters can ever be selected; the two-character selection moves with the cursor thereafter
  • When using Shift+Up/Down arrows, only one line can ever be selected; the selection moves with the cursor thereafter
  • Regardless of selection method, pressing Backspace or Delete will only ever delete the single character immediately before/after the cursor

Unaffected:

  • Mouse selection works as expected
  • Copying a selected range (with right-click or Ctrl+C) works as expected

I have tried...

  • Windows Terminal (my daily driver)
  • cmd.exe directly
  • Windows PowerShell directly
  • VS Code integrated terminal

All exhibit the same behavior.

This likely has something to do with the fact that Windows shells implement this behavior natively, but that's pure speculation.

I used the following "action" config in Windows Terminal to get Shift+Enter to work for soft newlines:

{
  "command": {
    "action": "sendInput",
    "input": "\u001b[13;2u"
  },
  "id": "User.sendInput.ShiftEnterCustom"
}

Is there anything similar I could try to get the Shift+Arrow, Backspace or Delete keys to work?

Plugins

No response

OpenCode version

1.2.18

Steps to reproduce

  1. Type a line of text (e.g., Lorem ipsum dolor sit amet)
  2. Pres Shift+LeftArrow four times to select "amet"
  • Expected: "amet" is selected, with cursor blinking on the 'a'
  • Actual: "am" is selected, with cursor blinking on 'a'

  1. Type a line of text (e.g., Lorem ipsum dolor sit amet)
  2. Press Shift+Home to select the whole line (this works!)
  3. Press Delete
  • Expected: The entire line of text is removed
  • Actual: The 'L' is removed, leaving "orem ipsum dolor sit amet", unselected, cursor blinking on 'o'

  1. Type a line of text (e.g., Lorem ipsum dolor sit amet)
  2. Press Home to move the cursor to the start of the line
  3. Press Shift+End to select the entire line (this works!)
  4. Press Backspace
  • Expected: The entire line of text is removed
  • Actual: The 't' at the end of "amet" is removed, leaving "Lorem ipsum dolor sit ame", unselected, cursor blinking at the end of the line

Screenshot and/or share link

No response

Operating System

Windows 11

Terminal

Windows Terminal

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingopentuiThis relates to changes in v1.0, now that opencode uses opentuiwindows

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions