Skip to content

Commit

Permalink
Added basic syntax highlighting to blame
Browse files Browse the repository at this point in the history
  • Loading branch information
JetpackDuba committed Aug 20, 2024
1 parent dfe9ebb commit 0dad158
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/kotlin/com/jetpackduba/gitnuro/ui/Blame.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -48,6 +49,8 @@ fun Blame(
onClose: () -> Unit,
) {

val fileExtension = filePath.split(".").lastOrNull()
val syntaxHighlighter = getSyntaxHighlighterFromExtension(fileExtension)
val focusRequester = remember { FocusRequester() }

LaunchedEffect(Unit) {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 0dad158

Please sign in to comment.