refreshVersions
refreshVersions copied to clipboard
Misalignment of delimiter in VersionsCatalogUpdater
- [x] I have read the guidelines for submitting issues
🐛 Describe the bug
The current ⬆ delimiter used by VersionsCatalogUpdater creates a misalignment on toml update lines.
⚠️ Current behavior
https://github.com/jmfayard/refreshVersions/blob/1dcf5a247b78ed7abdc981d48f59c68cd4191778/plugins/core/src/test/resources/toml-refreshversions/expected.libs.toml#L11-L14
✅ Expected behavior
short-notation = "some.plugin.id:1.4"
## ⬆ :1.5"
## ⬆ :1.6"
## ⬆ :1.7"
📱 Tech info
The following logic seems to be the issue:
https://github.com/jmfayard/refreshVersions/blob/1dcf5a247b78ed7abdc981d48f59c68cd4191778/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/VersionsCatalogUpdater.kt#L86-L92
The "magic numbers" seem to correspond to extra spaces, and therefore should rather be
val repeatCount = indexOfCurrentVersion - it - when {
canFitSpaceAfterAvailableSymbol -> 1
else -> 0
}
and I think we should deduce this from the trailingSpace instead, otherwise we don't catch both cases of the if.
https://github.com/jmfayard/refreshVersions/blob/1dcf5a247b78ed7abdc981d48f59c68cd4191778/plugins/core/src/main/kotlin/de/fayard/refreshVersions/core/internal/VersionsCatalogUpdater.kt#L92
So I would rewrite it to:
trailingSpace = if (canFitSpaceAfterAvailableSymbol && versionPrefix.startsWith(' ').not()) " " else ""
val repeatCount = indexOfCurrentVersion - it - trailingSpace.length
leadingSpace = " ".repeat(repeatCount.coerceAtLeast(0))
❓ Side question
What was the rationale for choosing this character ⬆? It seems to be interpreted as emoji (at least on my setup), and breaks mouse selection even more 🙈
Would you be open to replace it with a simpler ↑ unicode character that won't be parsed as emoji?
Mouse selection is cool, but have you tried keyboard selection?
Just hold shift and press the up arrow on your keyboard.
The fact that both keys, and the available update symbol are all upwards arrows should make it easier to remember 😉
Anyway, I will look into the details from my computer later, thanks for the report.
Yes, I use both, and keyboard navigation seemed broken as well on my end.
The fact that both keys, and the available update symbol are all upwards arrows should make it easier to remember 😉
I don't get what you mean 😕
On my work env (macos), the character is not rendered as emoji, but still has a different size in monospace font:
And multi-cursor selection does not work either (mouse & keyboard).
👋 Hi, can I help improve the situation in any way? This issue is currently labelled as https://github.com/jmfayard/refreshVersions/labels/ready-for-development.
Should we update the character from ⬆ to ↑ and fix the computed trailingSpace value?
It seems like it has been handled in https://github.com/Splitties/refreshVersions/commit/c75cab1c9a688017887d32b9d259fe7fd3646e35
Is the behavior correct on your side now in version 0.60.0?
The keyboard selection works, but the mouse selection does not in the IDE.
I don't think we can make it work on both sides without having a character of length 1 (i.e. ⬆ vs ↑).
How is mouse selection "not working"?
🙈 nevermind, I was testing a wrong assumption.
Mouse selection (click and drag) and keyboard selection (shift and arrows) works, and that's all that matters! ✅
Alright, I'm glad this was fixed!