kraken-core/: fix: Rework task description wrapping #98
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a follow-up to #94. It started because I noticed a boundary-condition bug where descriptions that came all the way up to right side of the terminal seemed to have an extra newline added to them. That turned out to be because every line got an extra space added to it, so all the lines ended up one character too long, and then regular terminal wrapping kicked in.
This caused me to dig further into how exactly the description-rendering code was set up, which led me to find some more oddities. So I decided to make two bigger changes to the code.
First, it no longer joins
line
by spaces, but instead joins by\n
, with every string-append to a line prefixing its own separator (+= " "
). This makes it easier to determine where line breaks actually come from, and avoids spurious spaces from appearing.And second, if there is so little room remaining on a line that it would look weird when wrapped (see code comment for how that's evaluated), the description is now moved to the next line and wrapped independently to 80 characters wide. If this happens, extra vertical spacing is also added before the next task.
I've tested this by adjusting the description and task status of a number of tasks and running
kraken q ls
to verify that the output (subjectively) looks readable and sane. That's also how I landed on 48 characters as the "right" place to flip between column and next-line mode.Some screenshots: