Skip to content

Unintended wrapping when using external splitter #158

@alantrick

Description

@alantrick

Consider the code:

use hyphenation;
use hyphenation::Load;
use textwrap;

let us_hyph = hyphenation::Standard::from_embedded(
    hyphenation::Language::EnglishUS).unwrap();
let input = "participation is the key to sucess";
let wrapper = textwrap::Wrapper::new(10);
let output = "participat\nion is the\nkey to\nsucess";
assert_eq!(output, wrapper.fill(input));
let wrapper = textwrap::Wrapper::with_splitter(10, us_hyph);
let output = "participa-\ntion\n \nis the key\nto sucess";
assert_eq!(output, wrapper.fill(input));
// expected output "participa-\ntion is the\nkey to\nsucess";

The first wrapper works okay (though it has to split the word in the middle) but the second wrapper with the hyphenator ends up having a blank third line instead of the expected result (in comments).

This might be a bug in the hyphenator library, but I'm not familiar enough with the code to know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions