Skip to content

Commit

Permalink
🐛 Fix available symbol for version catalog
Browse files Browse the repository at this point in the history
On some fonts, the arrow symbol was only 1 character wide instead of 2. Using a classic character negates this issue
  • Loading branch information
MaxMichel2 committed Aug 28, 2024
1 parent df624c0 commit e0e317a
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ internal class VersionsCatalogUpdater(
Version -> {
linesForUpdates(line, findLineReferencing(line))
}

Libs, Plugin -> {
val updates = dependenciesUpdates.firstOrNull {
it.moduleId.name == line.name && it.moduleId.group == line.group
Expand Down Expand Up @@ -71,7 +72,7 @@ internal class VersionsCatalogUpdater(
val isObject = initialLine.unparsedValue.endsWith("}")

val commentPrefix = "##"
val availableSymbol = ""
val availableSymbol = "^"
val versionPrefix = when {
isObject || initialLine.section == TomlSection.Versions -> """= """"
else -> """:"""
Expand All @@ -86,14 +87,13 @@ internal class VersionsCatalogUpdater(
yield(commentPrefix)
yield(availableSymbol)
yield(versionPrefix)
}.sumOf { it.length }.let {
it + 1 // Because the length of availableSymbol (⬆) is 1, but it takes the width of 2 chars in the IDE.
}.let {
val indexOfCurrentVersion = initialLine.text.indexOf(currentVersion)
val gap = indexOfCurrentVersion - it
leadingSpace = " ".repeat((gap - 1).coerceAtLeast(0))
trailingSpace = if (gap > 0 && versionPrefix.endsWith(' ').not()) " " else ""
}
}.sumOf { it.length }
.let {
val indexOfCurrentVersion = initialLine.text.indexOf(currentVersion)
val gap = indexOfCurrentVersion - it
leadingSpace = " ".repeat((gap - 1).coerceAtLeast(0))
trailingSpace = if (gap > 0 && versionPrefix.endsWith(' ').not()) " " else ""
}
return availableUpdates.mapTo(mutableListOf(initialLine)) { versionCandidate: MavenVersion ->
val version = versionCandidate.value
TomlLine(
Expand Down

0 comments on commit e0e317a

Please sign in to comment.