rememberSyntaxHighlightedString

fun rememberSyntaxHighlightedString(state: TextFieldState, language: Language, theme: SyntaxTheme = LocalSyntaxTheme.current): State<AnnotatedString>

Returns a State holding the syntax-highlighted form of state.text. The returned state recomputes incrementally as the user edits via the underlying IncrementalHighlighter.

The engine is owned by this hook: one instance per (state, language) lifetime, closed on recomposition leave or key change. theme changes do not rebuild the engine — the engine's theme-only short-circuit handles them.

Thread-safety: the engine is driven from a single coroutine on Dispatchers.Default; callers must not invoke update/close on a shared engine instance themselves.