1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-08 05:47:05 +09:00

DROID-2219 App | Tech | Release 6 stabilisation (#1570)

This commit is contained in:
Evgenii Kozlov 2024-09-18 16:07:40 +02:00
parent 083989ae9b
commit e8958a2dab

View file

@ -61,8 +61,12 @@ class CodeTextInputWidget : AppCompatEditText, SyntaxHighlighter {
}
private fun setupSyntaxHighlighter() {
addRules(context.obtainSyntaxRules(Syntaxes.KOTLIN))
highlight()
runCatching {
addRules(context.obtainSyntaxRules(Syntaxes.KOTLIN))
highlight()
}.onFailure {
Timber.e(it, "Error while setting up syntax highlighter")
}
super.addTextChangedListener(syntaxTextWatcher)
}
@ -129,17 +133,21 @@ class CodeTextInputWidget : AppCompatEditText, SyntaxHighlighter {
}
override fun setupSyntax(lang: String?) {
if (lang == null) {
rules.clear()
clearHighlights()
} else {
val result = context.obtainSyntaxRules(lang)
if (result.isEmpty()) {
addRules(context.obtainGenericSyntaxRules())
runCatching {
if (lang == null) {
rules.clear()
clearHighlights()
} else {
addRules(result)
val result = context.obtainSyntaxRules(lang)
if (result.isEmpty()) {
addRules(context.obtainGenericSyntaxRules())
} else {
addRules(result)
}
highlight()
}
highlight()
}.onFailure {
Timber.e(it, "Error while setting syntax rules.")
}
}