Slackbot
03/13/2021, 6:54 PMAyomide
03/13/2021, 6:56 PMval 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.lewis
03/13/2021, 7:07 PMAyomide
03/13/2021, 7:14 PM