diff --git a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/TomlSection.kt b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/TomlSection.kt index be256392..6fb0bc1d 100644 --- a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/TomlSection.kt +++ b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/TomlSection.kt @@ -6,13 +6,13 @@ internal sealed class TomlSection(open val name: String) { object Root: TomlSection("root") object Versions: TomlSection("versions") - object Plugins: TomlSection("plugins") - object Bundles: TomlSection("bundles") object Libraries: TomlSection("libraries") + object Bundles: TomlSection("bundles") + object Plugins: TomlSection("plugins") data class Custom(override val name: String) : TomlSection(name) companion object { - val orderedSections = listOf(Root, Bundles, Plugins, Versions, Libraries) + val orderedSections = listOf(Root, Versions, Libraries, Bundles, Plugins) fun from(name: String): TomlSection = orderedSections.firstOrNull { it.name == name } ?: Custom(name) } diff --git a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/VersionsCatalogUpdater.kt b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/VersionsCatalogUpdater.kt index 444cecd8..802cfaad 100644 --- a/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/VersionsCatalogUpdater.kt +++ b/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/VersionsCatalogUpdater.kt @@ -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 @@ -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 -> """:""" @@ -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(