Skip to content

Commit

Permalink
fix line numbers were blinking on typing
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny-chung committed Feb 11, 2024
1 parent 31f4f64 commit 2622cca
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,17 @@ fun LineNumbersView(modifier: Modifier = Modifier, scrollState: ScrollState, tex
fontFamily = FontFamily.Monospace,
color = colours.unimportant,
)
val lineNumDigits = "${(lineTops?.size ?: 2) - 1}".length
log.v { "LineNumbersView ${size != null} && ${textLayoutResult != null} && ${lineTops != null}" }
var lastTextLayoutResult by remember { mutableStateOf(textLayoutResult) }
var lastLineTops by remember { mutableStateOf(lineTops) }

val textLayoutResult = textLayoutResult ?: lastTextLayoutResult
val lineTops = lineTops ?: lastLineTops

lastTextLayoutResult = textLayoutResult
lastLineTops = lineTops

val lineNumDigits = lineTops?.let { "${it.lastIndex}".length } ?: 1
val width = rememberLast(lineNumDigits) {
maxOf(textMeasurer.measure("8".repeat(lineNumDigits), textStyle, maxLines = 1).size.width.toDp(), 20.dp) +
4.dp + 8.dp
Expand Down

0 comments on commit 2622cca

Please sign in to comment.