From 6917b9b9682946639aea043c0b5c13656cdd0962 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Thu, 12 Apr 2018 13:05:22 +0200 Subject: [PATCH] Fix StringJustifier error with dashes (-) --- src/be/nikiroo/utils/StringJustifier.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/be/nikiroo/utils/StringJustifier.java b/src/be/nikiroo/utils/StringJustifier.java index 9ea0b72..ed20291 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; } } -- 2.27.0