rust-windowing / rust-windowing/winit

macOS: Dictation (voice input) silently drops text — selectedRange returns NSNotFound

Open Beginner friendly
#4,666 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

B - bug DS - appkit
Dominant language
Rust
Stars
6.2k
Forks
1.3k
Avg merge
2d 19h
Merged PRs (30d)
9

Description

Description

Summary
On macOS, dictated text never reaches the focused winit window. The system dictation UI (mic icon / flyout) activates and shows recognized words, but nothing is inserted into the app.

Root cause
macOS dictation delivers transcribed text through the same NSTextInputClient path used for IME composition — via insertText:replacementRange: — but only after confirming a valid insertion point by querying selectedRange. Winit's macOS NSView implementation (src/platform_impl/macos/view.rs) returns NSNotFound from selectedRange rather than a real range. macOS interprets NSNotFound as "no valid cursor position" and discards the dictated text before ever calling insertText:replacementRange:.

This appears to be the same underlying gap tracked in #3617 ("selected_range and replacement_range parameters are ignored"), surfacing here specifically as a dictation regression rather than an IME composition bug.

Expected fix
Have selectedRange in winit's NSTextInputClient impl return a valid NSRange (e.g. NSRange::new(0, 0) when there's no real selection tracking) instead of NSNotFound. Ideally firstRectForCharacterRange: should also return a real rect so the dictation indicator positions correctly near the cursor, but the selectedRange fix alone is what unblocks text delivery.

Impact
Affects every winit-based macOS app that hasn't separately worked around this (Neovide, Alacritty-style terminals, etc.) — accessibility-relevant, since dictation is a primary input method for some users.

macOS version
mac os
26.6.1
Winit version

0.30.13

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/platform_impl/macos/view.rs and inspect the NSTextInputClient implementation, especially selectedRange. Confirm how the current NSNotFound result affects macOS dictation, then make selectedRange return a valid range as described in the issue. Verify that dictated text reaches the focused winit window; firstRectForCharacterRange: is an optional follow-up for indicator positioning.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, rust
Domain
desktop
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.