From: Niki Roo Date: Thu, 12 Apr 2018 11:05:22 +0000 (+0200) Subject: Fix StringJustifier error with dashes (-) X-Git-Tag: fanfix-swing-0.0.1~21^2~208 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=6917b9b9682946639aea043c0b5c13656cdd0962;p=fanfix-swing.git Fix StringJustifier error with dashes (-) --- diff --git a/src/be/nikiroo/utils/StringJustifier.java b/src/be/nikiroo/utils/StringJustifier.java index 9ea0b725..ed202911 100644 --- a/src/be/nikiroo/utils/StringJustifier.java +++ b/src/be/nikiroo/utils/StringJustifier.java @@ -26,6 +26,9 @@ * * @author Kevin Lamonte [kevin.lamonte@gmail.com] * @version 1 + * + * I added some changes to integrate it here. + * @author Niki */ package be.nikiroo.utils; @@ -220,8 +223,14 @@ class StringJustifier { if ((i + 1) < line.length()) { char car = line.charAt(i); char nextCar = line.charAt(i + 1); - if (nextCar == ' ' || car == '-' || nextCar == '-') { + if (car == ' ' || car == '-' || nextCar == ' ') { needDash = false; + } else if (i > 0) { + char prevCar = line.charAt(i - 1); + if (prevCar == ' ' || prevCar == '-') { + needDash = false; + i--; + } } } @@ -238,8 +247,8 @@ class StringJustifier { // no dash before parenthesis (but cannot add one more // after) if ((i + 1) < line.length()) { - char car = line.charAt(i + 1); - if (car == '(' || car == ')') { + char nextCar = line.charAt(i + 1); + if (nextCar == '(' || nextCar == ')') { needDash = false; } }