Skip to content

Commit

Permalink
fix TableOutput spaces when using long words (DAT-10069) (#2879)
Browse files Browse the repository at this point in the history
Outputting long lines with a single word that spans over multiple lines caused the next word to be appended directly without a space.
  • Loading branch information
StevenMassaro committed May 31, 2022
1 parent 4ab687b commit a433639
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions liquibase-core/src/main/java/liquibase/util/TableOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ private static String padColumn(String col, int maxWidth) {
* @return the new current running width
*/
private static int doAppend(int runningWidth, String part, int maxWidth, StringBuilder result) {
// If a word that is longer than the maxWidth is appended before this method is called, it will spill onto
// multiple lines, and we only care about the runningWidth of the last line.
if (runningWidth > maxWidth) {
runningWidth = runningWidth % maxWidth;
}
int spaceWidth = runningWidth > 0 ? 1 : 0;
if (runningWidth + (part.length() + spaceWidth) > maxWidth) {
runningWidth = fillLineWithSpaces(runningWidth, maxWidth, result);
Expand Down

0 comments on commit a433639

Please sign in to comment.