Per-app option to show composition only in the candidate panel, without calling setMarkedText (works around a Terminal.app 2.15 crash on macOS 27)

Open
#1,186 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
swift
Domain
desktop

Research direction

Start with the placeholder marked-text logic in SquirrelInputController and the per-app handling of no_inline and inline_preedit in app_options. Add a no_marked_text option that implies no_inline and stops any setMarkedText: call for that client, sending text only through insertText:. Done means a client with the option never receives marked text, the candidate panel still shows the composition, and the default behavior is unchanged. Confirm the cursor position still comes from attributesForCharacterIndex: and firstRectForCharacterRange:.

Written by the indexing model from the issue text.

Description

Summary

On macOS 27.0.1, Terminal.app 2.15 (488) crashes or drops its window when an input method keeps marked text in the view while the pty keeps producing output (e.g. tmux with a status line / clock / several panes). The fault is in Terminal (-[TTView setMarkedText:…] → -[TTLogicalScreen displayPositionForUnicharOffset:] → NSRangeException; reported to Apple), not in Squirrel — but Squirrel is the only side a user can change today.

Squirrel currently always keeps marked text in the client:

  • inline_preedit: true → the composition string is the marked text;
  • no_inline: true → Squirrel still sets a placeholder marked text (a full-width space, the iTerm2 workaround in SquirrelInputController), so Terminal still re-anchors a marked range on every output batch.

Either way Terminal walks the broken path. We measured 17 NSRangeException events in 10 hours and 6 hard crashes in 5 days on one machine, every one of them within the same second as a Squirrel "Setting marked text" IMK log line.

Request

A per-app option (in app_options), e.g. no_marked_text: true, meaning: never call setMarkedText: for this client; show the raw composition only in the candidate panel (preedit line), and send text only via insertText:. For Terminal that completely avoids the Apple bug, and the UI loss is small (no inline preedit, which Terminal users with no_inline: true already accept).

Suggested semantics:

  • no_marked_text: true implies no_inline: true (panel shows the preedit).
  • No placeholder marked text is set; cursor position for the panel is taken from the client's attributesForCharacterIndex: / firstRectForCharacterRange: of the current insertion point, as today.
  • Default false, so nothing changes for existing users.

Evidence (available on request)

  • 6 Terminal crash logs (.ips), symbolicated against Terminal's ObjC method table: crash path is -[TTView drawRect:] → drawAttributedString:…isTextMarked:… → -[TTLogicalScreen unicharOffsetForDisplayPosition:] → expandUnicharOffsetCacheToLine: → NSRangeException → +[NSApplication _crashOnException:].
  • Logged (non-fatal) path: TTIOManager mainThread → TTTabController shellDidReceiveData: → TTVT100Emulator decodeData: → -[TTView setMarkedText:selectedRange:replacementRange:] → displayPositionForUnicharOffset: → NSRangeException, after which the window content is corrupted / the window closes.
  • Disassembly of expandUnicharOffsetCacheToLine: shows the bounds check (line >= lineCount → raise).
  • Apple Feedback Assistant report filed in parallel (FB number will be added here once assigned).

Environment

macOS 27.0.1 (26A434), Mac16,10; Terminal 2.15 (488); Squirrel 1.1.2; rime-liur schema; tmux 3.7c.

Dominant language
Swift
Stars
6.6k
Forks
586
Avg merge
1d 19h
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from rime/squirrel

All issues in rime/squirrel

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.