[PR #15758] Add an experimental setting for moving the cursor with the mouse #30724

Open
opened 2026-01-31 09:42:36 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/15758

State: closed
Merged: Yes


Summary of the Pull Request

This adds a new experimental per-setting to the terminal.

"experimental.moveCursorWithMouse": bool

When:

  • the setting is on
  • AND you turn on shell integration (at least 133;B)
  • AND you click is somewhere after the "active command" mark

we'll send a number of simulated keystrokes to the terminal based off the number of cells between the place clicked and where the current mouse cursor is.

PR Checklist

  • Related to #8573. I'm not marking as closed, because we should probably polish this before we close that out. This is more a place to start.

Detailed Description of the Pull Request / Additional comments

There was a LOT of discussion in #8573. This is kinda a best effort feature - it won't always work, but it should improve the experience most of the time. We all kinda agreed that as much as the shell probably should be responsible for doing this, there's myriad reasons that won't work in practicality:

  • That would also disable selection made by the terminal. That's a hard sell.
  • We'd need to invent some new mouse mode to support click-to-reposition-but-drags-to-select-I-don't-want
  • We'd then need shells to adopt that functionality.

And eventually settled that this was the least horrifying comprimise.

This has e d g e c a s e s:

  • Does it work for wrapped lines? Well, kinda okay actually.
  • Does it work for vim/emacs? Nope.
  • Does it work for emoji/wide glyphs? I wouldn't expect it to! I mean, emoji input is messed up anyways, right?
  • Other characters like ESC (which are rendered by the shell as two cells "^[")? Nope.
  • Does it do selections? Nope.
  • Clicking across lines with continuation prompts? Nope.
  • Tabs? Nope.
  • Wraps within tmux/screen? Nope.

https://github.com/xtermjs/xterm.js/blob/master/src/browser/input/MoveToCell.ts has probably a more complete implementation of how we'd want to generate the keypresses and such.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/15758 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request This adds a new experimental per-setting to the terminal. ```ts "experimental.moveCursorWithMouse": bool ``` When: * the setting is on * AND you turn on shell integration (at least `133;B`) * AND you click is somewhere _after_ the "active command" mark we'll send a number of simulated keystrokes to the terminal based off the number of cells between the place clicked and where the current mouse cursor is. ## PR Checklist - [ ] Related to #8573. I'm not marking as _closed_, because we should probably polish this before we close that out. This is more a place to start. ## Detailed Description of the Pull Request / Additional comments There was a LOT of discussion in #8573. This is kinda a best effort feature - it won't always work, but it should improve the experience _most of the time_. We all kinda agreed that as much as the shell probably should be responsible for doing this, there's myriad reasons that won't work in practicality: * That would also disable selection made by the terminal. That's a hard sell. * We'd need to invent some new mouse mode to support click-to-reposition-but-drags-to-select-I-don't-want * We'd then need shells to adopt that functionality. And eventually settled that this was the least horrifying comprimise. This has _e d g e c a s e s_: * Does it work for wrapped lines? Well, kinda okay actually. * Does it work for `vim`/`emacs`? Nope. * Does it work for emoji/wide glyphs? I wouldn't expect it to! I mean, emoji input is messed up anyways, right? * Other characters like `ESC` (which are rendered by the shell as two cells "^[")? Nope. * Does it do selections? Nope. * Clicking across lines with continuation prompts? Nope. * Tabs? Nope. * Wraps within tmux/screen? Nope. https://github.com/xtermjs/xterm.js/blob/master/src/browser/input/MoveToCell.ts has probably a more complete implementation of how we'd want to generate the keypresses and such.
claunia added the pull-request label 2026-01-31 09:42:36 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#30724