Text: Fixed extractLines where hyphenation is off

This commit is contained in:
Paul Beckingham 2016-02-23 22:15:00 -05:00
parent db3cfc939d
commit 716936acaa
2 changed files with 5 additions and 5 deletions

View file

@ -291,7 +291,7 @@ bool extractLine (
// No hyphenation, just truncation.
else
{
line = text.substr (offset, prior_cursor - offset);
line = text.substr (offset, cursor - offset);
offset = cursor;
return true;
}
@ -630,7 +630,7 @@ std::string leftJustify (const int input, const int width)
////////////////////////////////////////////////////////////////////////////////
std::string leftJustify (const std::string& input, const int width)
{
auto len = utf8_text_width (input);
auto len = static_cast <int> (utf8_text_width (input));
if (len == width)
return input;
@ -660,7 +660,7 @@ std::string rightJustify (const int input, const int width)
////////////////////////////////////////////////////////////////////////////////
std::string rightJustify (const std::string& input, const int width)
{
auto len = utf8_text_width (input);
auto len = static_cast <int> (utf8_text_width (input));
if (len == width)
return input;
@ -668,7 +668,7 @@ std::string rightJustify (const std::string& input, const int width)
if (len > width)
return input.substr (0, width);
return (((unsigned int) width > len)
return ((width > len)
? std::string (width - len, ' ')
: "")
+ input;

View file

@ -54,7 +54,7 @@ class TestHyphenation(TestCase):
"""Verify hyphenation in the absence of white space"""
self.t("add AAAAAAAAAABBBBBBBBBBCCCCCCCCCC")
code, out, err = self.t("ls")
self.assertIn("1 AAAAAAAAAABBBB-\n", out)
self.assertIn(" 1 AAAAAAAAAABBBBBB-\n", out)
class TestBug804(TestCase):
def setUp(self):