-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed diff highlight when wrapping text and it's combined with syntax…
… highlighting
- Loading branch information
1 parent
db06460
commit 372ba1a
Showing
4 changed files
with
183 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/test/kotlin/com/jetpackduba/gitnuro/ui/diff/syntax_highlighter/SyntaxHighlighterTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.jetpackduba.gitnuro.ui.diff.syntax_highlighter | ||
|
||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.AnnotatedString | ||
import androidx.compose.ui.text.SpanStyle | ||
import org.junit.jupiter.api.Test | ||
|
||
import org.junit.jupiter.api.Assertions.* | ||
|
||
class SyntaxHighlighterTest { | ||
|
||
@Test | ||
fun syntaxHighlight() { | ||
val annotatedString = AnnotatedString.Builder() | ||
|
||
annotatedString.append("val variable = \"Hello ") | ||
annotatedString.append(AnnotatedString("World", SpanStyle(color = Color.Blue))) | ||
annotatedString.append("\"") | ||
|
||
val syntaxHighlighter = getSyntaxHighlighterFromExtension("kt") | ||
val result = syntaxHighlighter.syntaxHighlight( | ||
annotatedString.toAnnotatedString(), | ||
commentColor = Color.Green, | ||
keywordColor = Color.Cyan, | ||
annotationColor = Color.Yellow, | ||
) | ||
|
||
assertTrue( | ||
result.spanStyles.contains( | ||
AnnotatedString.Range( | ||
SpanStyle(Color.Cyan), | ||
start = 0, | ||
end = 3, | ||
) | ||
) | ||
) | ||
} | ||
} |