Skip to content

Restyle a paragraph up to the end throws indexes off #1310

@Symeon94

Description

@Symeon94

I was working on refactoring the Paragraph class after having added tests and I looked at the bugs I highlighted in the PR adding the tests. I think it deserves its own issue, that's why I'm creating it here.

I'm refactoring the method, but I'm not modifying its behaviour for now, I will do that on a separate PR.

I have yet to figure out what is happening.

If you restyle a Paragraph up to len - 1 you don't have any issue, but you do if you restyle up to len. As you can see in below test, the indexes in that cases are way off.

checkStyle(p3, 18, new String[] {"text", "unknown", "keyword", "text"},
	0, 3, // text
	3, 10, // unknown
	10, 12, // keyword
	12, 18); // text

// Restyle up to the end
checkStyle(p3.restyle(11, 17, "out"), 18, new String[] {"text", "unknown", "keyword", "out", "text"},
	0, 3,
	3, 10,
	10, 11,
	11, 17,
	17, 18);

// Restyle up to the end - Bug: indexes are totally of
checkStyle(p3.restyle(11, 18, "out"), 18, new String[] {"text", "unknown", "keyword", "out"},
	0, 3,
	3, 10,
	0, 1,
	0, 7);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions