Browse Source

Fixed a crash when selecting empty rows in codeviewer example (#3854)

Due to [known
problem](https://partnerissuetracker.corp.google.com/issues/199919707),
the application crashes when selecting lines with empty text.
The fix does 2 things:
- Prevents `SelectionContainer` from crashing
- Improves format of copied text by separating it into lines
pull/3864/head
Andrei Salavei 1 year ago committed by GitHub
parent
commit
9e25001e9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorView.kt

4
examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorView.kt

@ -182,6 +182,10 @@ private fun codeString(str: String) = buildAnnotatedString {
addStyle(AppTheme.code.value, strFormatted, Regex("[0-9]+")) addStyle(AppTheme.code.value, strFormatted, Regex("[0-9]+"))
addStyle(AppTheme.code.annotation, strFormatted, Regex("^@[a-zA-Z_]*")) addStyle(AppTheme.code.annotation, strFormatted, Regex("^@[a-zA-Z_]*"))
addStyle(AppTheme.code.comment, strFormatted, Regex("^\\s*//.*")) addStyle(AppTheme.code.comment, strFormatted, Regex("^\\s*//.*"))
// Keeps copied lines separated and fixes crash during selection:
// https://partnerissuetracker.corp.google.com/issues/199919707
append("\n")
} }
} }

Loading…
Cancel
Save