-
Notifications
You must be signed in to change notification settings - Fork 0
Fix unified view to show both old and new text for changed lines with syntax highlighting #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
Co-authored-by: JahidHasanCO <50579963+JahidHasanCO@users.noreply.github.com>
Co-authored-by: JahidHasanCO <50579963+JahidHasanCO@users.noreply.github.com>
Co-authored-by: JahidHasanCO <50579963+JahidHasanCO@users.noreply.github.com>
| Text( | ||
| text = oldLineNumber.toString(), | ||
| modifier = Modifier | ||
| .width(40.dp) |
Check warning
Code scanning / detekt
Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning
| Text( | ||
| text = "", | ||
| modifier = Modifier | ||
| .width(40.dp) |
Check warning
Code scanning / detekt
Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning
| // Prefix for deletion | ||
| Text( | ||
| text = "-", | ||
| modifier = Modifier.padding(end = 4.dp), |
Check warning
Code scanning / detekt
Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning
| Text( | ||
| text = "", | ||
| modifier = Modifier | ||
| .width(40.dp) |
Check warning
Code scanning / detekt
Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning
| Text( | ||
| text = newLineNumber.toString(), | ||
| modifier = Modifier | ||
| .width(40.dp) |
Check warning
Code scanning / detekt
Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning
| Text(text = entry.newLine?.let { newLineNumber.toString() } | ||
| ?: "", | ||
| modifier = Modifier | ||
| .width(40.dp) |
Check warning
Code scanning / detekt
Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning
| // Prefix | ||
| Text( | ||
| text = prefix, | ||
| modifier = Modifier.padding(end = 4.dp), |
Check warning
Code scanning / detekt
Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning
| @@ -0,0 +1,108 @@ | |||
| package dev.jahidhasanco.diffly.presentation.component | |||
Check warning
Code scanning / detekt
Checks whether files end with a line separator. Warning test
| class UnifiedCharDiffTextTest { | ||
|
|
||
| @Test | ||
| fun testUnifiedViewLogicWithChangedEntries() { |
Check warning
Code scanning / detekt
One method should have one responsibility. Long methods tend to handle many things at once. Prefer smaller methods to make them easier to understand. Warning test
| } | ||
| DiffType.UNCHANGED -> { | ||
| val line = entry.oldLine ?: "" | ||
| renderedLines.add("${oldLineNumber.toString().padStart(3)} ${newLineNumber.toString().padStart(3)} $line") |
Check warning
Code scanning / detekt
Line detected that is longer than the defined maximum line length in the code style. Warning test
Problem
The unified view in Diffly was only displaying the new version of changed lines, making it impossible for users to see what the original text looked like. This defeated the purpose of a diff tool, as users couldn't understand what actually changed.
Before:
Solution
Modified
UnifiedCharDiffText.ktto properly handleDiffType.CHANGEDentries by displaying both the old and new versions of changed lines, following standard unified diff format:After:
Key Changes
DiffType.CHANGEDentries, now renders both old line (with-prefix) and new line (with+prefix)Testing
Added
UnifiedCharDiffTextTest.ktto verify the logic handles all diff types correctly and produces the expected unified diff format.Fixes #3.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
dl.google.com/usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -Xmx4608m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.11.1-bin/bpt9gzteqjrbo1mjrsomdt32c/gradle-8.11.1/lib/gradle-daemon-main-8.11.1.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.11.1-bin/bpt9gzteqjrbo1mjrsomdt32c/gradle-8.11.1/lib/agents/gradle-instrumentation-agent-8.11.1.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.11.1(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.