rememberHighlightedStringAsync
Async variant of rememberHighlightedString that runs highlight off the calling thread.
The returned State holds the plain code (with SyntaxTheme.baseStyle applied) until the highlight computation finishes, then updates to the styled AnnotatedString. Use this for code blocks large enough that synchronous highlighting drops frames during recomposition; for typical inline code the synchronous rememberHighlightedString is the right choice.
When any of code, language, theme, or context changes, the previous coroutine is cancelled, the state immediately resets to the plain-text representation of the new code, and a fresh highlight computation is scheduled on context. An in-flight native parse() call cannot be cancelled mid-flight (it is a JNI call); only the Kotlin coroutine is cancelled, so its result is discarded but the native parse runs to completion.
Unlike rememberHighlightedString, the async variant does not cache the parsed tree across theme-only changes — sharing a Tree across coroutines would require io.github.treesitter.ktreesitter.Tree.copy for thread safety, which is not worth the complexity for the rare large-file + theme-toggle combination. Theme changes therefore re-trigger a full async parse.
Parameters
Coroutine context the highlight runs on. Defaults to Dispatchers.Default (the right choice for CPU-bound work). Override for tests or to share a thread pool.