👻 Ghost Text Simulator Spec
⚡ 1. Transaction Filtering (EditorState.transactionFilter)
- Intercept & Inspect: Track document modifications.
- Clear State: If changes occur outside the current cursor offset → Nuke pending suggestion.
- Type-Matching: If typing matches the suggestion prefix → Keep suggestion & update display.
💾 2. Decoration State Field (StateField)
- Schema:
State = { text: string, from: number } | null
- Lifecycle: Computes next state via transaction effects.
- Output: Returns
DecorationSet mapping a WidgetDecoration at from.
- DOM Generation: Creates a
<span> element.
- CSS Styling: Faint color (e.g.,
#888), italicized, user-select: none, pointer-events: none.
- Cursor Behavior: Ignored by cursor; editor cursor skips over the widget natively.
⌨️ 4. Keymap Bindings (High-Priority)
Tab (Accept): Inserts suggestion text at cursor → clears state.
Escape (Dismiss): Clears state → removes widget.
- Note: Precedence must override default autocomplete/indentation maps.