← 返回首页
Support stylus/pen text selection on Android by DaniilBabanin · Pull Request #7841 · coder/code-server · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

Support stylus/pen text selection on Android#7841

Open
DaniilBabanin wants to merge 1 commit into
coder:mainfrom
DaniilBabanin:android-pen-selection
Open

Support stylus/pen text selection on Android#7841
DaniilBabanin wants to merge 1 commit into
coder:mainfrom
DaniilBabanin:android-pen-selection

Conversation

Copy link
Copy Markdown

What this does

A stylus or pen drag now selects text in the editor on Android, the same as it
already does on iOS. A finger drag still scrolls, and the mouse is unchanged.

Why

The editor only sends pointer input through PointerEventHandler, the handler
that lets a pen select while touch scrolls, on iOS or on Android when
platform.isMobile is true. platform.isMobile looks for a "Mobi" token in the
user agent, and Android tablets usually leave that token out. So on a tablet the
editor fell back to TouchHandler, and a stylus could only scroll, never select.
Android phones were unaffected because their user agent carries "Mobi".

Background: microsoft/vscode#198578 added the pen/stylus selection path for
mobile; this extends it to Android tablets.

The change

One line, in a new patch (patches/pen-support.diff):

- const isPhone = platform.isIOS || (platform.isAndroid && platform.isMobile); + const isPhone = platform.isIOS || platform.isAndroid;

The iOS branch is left as is. The only difference is that Android no longer
requires the isMobile flag to reach PointerEventHandler.

Testing

Built and run on a Samsung tablet with an S Pen, in Chrome:

  • Pen drag across text selects it.
  • Finger drag scrolls.
  • Pen barrel button plus a tap opens the context menu.
  • Mouse selection and right-click are unchanged.

Also reproducible in desktop Chrome with DevTools device mode set to an Android
tablet user agent that has no "Mobi" token.

Notes

iPad and iPhone are unaffected; the iOS branch is untouched. Android phones are
unaffected too, since they already satisfied isMobile.

The editor only used the pen-aware PointerEventHandler on iOS, or on Android when platform.isMobile was true. That flag comes from a "Mobi" token in the user agent, which Android tablets usually leave out, so on a tablet the editor fell back to TouchHandler and a stylus could only scroll, not select. Widen the check to any Android device when Pointer Events are available, the same as iOS already does. The iOS branch is unchanged.
DaniilBabanin requested a review from a team as a code owner June 8, 2026 23:01

Copy link
Copy Markdown
Member

I feel this change should be made to VS Code directly rather than maintained as a patch here. Could we try submitting it upstream?

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Footer

© 2026 GitHub, Inc.