Skip to content

macOS: Implement surrounding text capability - #4785

Open
dzfrias wants to merge 1 commit into
rust-windowing:masterfrom
dzfrias:macos-delete-surrounding
Open

dzfrias wants to merge 1 commit into
rust-windowing:masterfrom
dzfrias:macos-delete-surrounding

Conversation

@dzfrias

@dzfrias dzfrias commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

macOS now has support for surrounding text. I extended the existing delete surrounding API. Note that there is a difference between what macOS says to do (which is to replace an arbitrary range) and what the API allows (which is to delete bytes before and after the cursor). This means the implementation has to translate between the two.

I tested this using the Japanese Romaji keyboard. Committing a composition, and then typing CTRL-Shift-R deletes some preceding text and reactivates marked text, which involves both selectedText and attributedSubstring. I also tested dictation, which worked. Another example of an IME that uses this feature is Zhuyin, but it isn't testable using the IME example program. Eventually I plan to add cursor support to ime.rs so that Zhuyin can be tested.

  • Tested on all platforms changed
  • Added an entry to the changelog module if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior

Fixes: #3617 (and maybe others)

@dzfrias
dzfrias requested a review from madsmtm as a code owner October 21, 2026 21:56
@dzfrias
dzfrias force-pushed the macos-delete-surrounding branch 2 times, most recently from 8739d32 to 1793f75 Compare October 22, 2026 18:52
@dzfrias
dzfrias force-pushed the macos-delete-surrounding branch from 1793f75 to 637e29a Compare October 26, 2026 04:17

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Both _selected_range and _replacement_range parameters are ignored in NSTextInputClient implementation.

1 participant