IME engine: an editor's own end of composition interrupts the OS composition; resets end only with their own completion

EditorState.composing replaces EditorState.revision (and TextEditorHost::revision): an editor that reported
composing and now does not ended the composition itself (a press in its text, a selection, an app edit over the
marked text), and the engine interrupts the OS composition and drops its late events. TextEditor and the sheet
grid report their marked text; editors that show none report false throughout.

The reset fence ends only with the completion of the engine's latest request (ImeResetId); an earlier request's
completion is stale. A request the integration can no longer answer (a pass with no IME output, an unfocused
window) is retired and asked again when an owner returns.

Trials: preedit and a click during composition for a canvas TextEditor, with one press per pass holding the late
commit for the next pass (craft-text); reset requests and stale completions (craft-ui-contract).
This commit is contained in:
aiongg
2026-11-13 16:15:16 +00:00
parent 957e2282c4
commit f910b4fe3c
13 changed files with 198 additions and 95 deletions
+2 -2
View File
@@ -2656,8 +2656,8 @@ Painters, `Draw`, the sensing core, the text adapter and `ImeSurface`.
- `craft_ui::primitives::EditorPurpose`: `pub enum EditorPurpose { Text, Code, Number, Password }`. What an editor part edits.
- `craft_ui::primitives::EditorRun`: `pub struct EditorRun<'a> { pub bytes: Range<usize>, pub rtl: bool, pub positions: &'a [f32], pub widths: &'a [f32] }`. One bidi run of a line: its bytes, direction, each character's start offset and advance.
- `pub const fn new(bytes: Range<usize>, rtl: bool, positions: &'a [f32], widths: &'a [f32]) -> Self`. A run over `bytes`.
- `craft_ui::primitives::EditorState`: `pub struct EditorState<'a> { pub caret: Rect, pub lines: &'a [EditorLine<'a>], pub caret_at: TextPos, pub selection: Option<(TextPos, TextPos)>, pub revision: u64, pub can_undo: bool, pub can_redo: bool }`. What an own-caret editor reports once per frame for the IME and AccessKit.
- `pub const fn new(caret: Rect, lines: &'a [EditorLine<'a>], caret_at: TextPos, revision: u64) -> Self`. A state with no selection and nothing to undo.
- `craft_ui::primitives::EditorState`: `pub struct EditorState<'a> { pub caret: Rect, pub lines: &'a [EditorLine<'a>], pub caret_at: TextPos, pub selection: Option<(TextPos, TextPos)>, pub composing: bool, pub can_undo: bool, pub can_redo: bool }`. What an own-caret editor reports once per frame for the IME and AccessKit.
- `pub const fn new(caret: Rect, lines: &'a [EditorLine<'a>], caret_at: TextPos) -> Self`. A state with no selection, no marked text and nothing to undo.
- `craft_ui::primitives::FacesCx`: `pub trait FacesCx`. Where a document face is asked for: a component's context, its measure or a content painter.
- `fn document_face(&self, key: &str, load: impl FnOnce() -> Option<FaceBytes>) -> FaceState`. The face registered under `key` as a family of its own. `load` runs only for a new key within the frame's
- `craft_ui::primitives::FakeThumbSource`: `pub struct FakeThumbSource<K>`. A [`ThumbSource`] for stories and tests in every crate: pictures made from the key and a revision the test sets,