This message was deleted.
s
This message was deleted.
a
Copy code
val semanticTokens by editorViewModel.semanticTokens.observeAsState(emptyList())
    TextField(
        value = currentFile,
        onValueChange = { editorViewModel.editCurrentFile(it) },
        textStyle = TextStyle(color = Color.White, fontSize = 15.sp),
        modifier = Modifier
            .fillMaxWidth()
            .verticalScroll(rememberScrollState()),
        visualTransformation = { text ->
            val lineIndexes = text.indices.filter { text[it] == '\n' || it == 0 }.map {
                if (it == 0) {
                    0
                } else {
                    it + 1
                }
            }
            TransformedText(
                AnnotatedString(
                    text = text.text,
                    spanStyles = if (text.isNotEmpty()) {
                        styleSemanticTokens(semanticTokens,editorViewModel,lineIndexes) + styleDiagnostics(diagnostics, editorViewModel, lineIndexes)
                    } else {
                        emptyList()
                    }
                ), OffsetMapping.Identity)
        },
    )
This is the minimum code snippet, the important bit is the
semanticTokens
variable, that I'm observing from the view model.
l
What causes semanticTokens to change?
a
A network request in the background. But that happens as soon the file is "opened". I can confirm it happens by looking at debug output. It's just the TextField doesn't update until I click on it