From 0dad1582757af3f44f977f3f982d999d1531377e Mon Sep 17 00:00:00 2001 From: Abdelilah El Aissaoui Date: Tue, 20 Aug 2024 23:01:30 +0200 Subject: [PATCH] Added basic syntax highlighting to blame --- src/main/kotlin/com/jetpackduba/gitnuro/ui/Blame.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/ui/Blame.kt b/src/main/kotlin/com/jetpackduba/gitnuro/ui/Blame.kt index eab313b7..cd80848b 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/ui/Blame.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/ui/Blame.kt @@ -37,6 +37,7 @@ import com.jetpackduba.gitnuro.theme.secondarySurface import com.jetpackduba.gitnuro.theme.tertiarySurface import com.jetpackduba.gitnuro.ui.components.PrimaryButton import com.jetpackduba.gitnuro.ui.components.ScrollableLazyColumn +import com.jetpackduba.gitnuro.ui.diff.syntax_highlighter.getSyntaxHighlighterFromExtension import org.eclipse.jgit.blame.BlameResult import org.eclipse.jgit.revwalk.RevCommit @@ -48,6 +49,8 @@ fun Blame( onClose: () -> Unit, ) { + val fileExtension = filePath.split(".").lastOrNull() + val syntaxHighlighter = getSyntaxHighlighterFromExtension(fileExtension) val focusRequester = remember { FocusRequester() } LaunchedEffect(Unit) { @@ -118,7 +121,7 @@ fun Blame( } Text( - text = line + blameResult.resultContents.lineDelimiter, + text = syntaxHighlighter.syntaxHighlight(line + blameResult.resultContents.lineDelimiter), color = MaterialTheme.colors.onBackground, modifier = Modifier.padding(vertical = 8.dp, horizontal = 16.dp), fontFamily = notoSansMonoFontFamily,