~eliasnaur/gio

9f62230c380f29d346663db2acf96aba86cafc65 — Chris Waldon 2 years ago f7c14e9
widget: adjust editor tests to new pos iteration

This commit fixes the expectations of our ligature iteration tests to
match the new behavior of the text position iterator. Now the cursor
can reach the position after the final glyph on a line, if that glyph
is not a newline.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
1 files changed, 4 insertions(+), 7 deletions(-)

M widget/editor_test.go
M widget/editor_test.go => widget/editor_test.go +4 -7
@@ 421,16 421,13 @@ func TestEditorLigature(t *testing.T) {
	// Ensure that all runes in the final cluster of a line are properly
	// decoded when moving to the end of the line. This is a regression test.
	e.moveEnd(selectionClear)
	// Because the first line is broken due to line wrapping, the last
	// rune of the line will not be before the cursor.
	assertCaret(t, e, 0, 13, len("fflffl fflffl"))
	// The first line was broken by line wrapping, not a newline character. As such,
	// the cursor can reach the position after the final glyph (a space).
	assertCaret(t, e, 0, 14, len("fflffl fflffl "))
	e.moveLines(1, selectionClear)
	// Because the space is at the beginning of the second line and
	// the second line is the final line, there are two more runes
	// before the cursor than on the first line.
	assertCaret(t, e, 1, 13, len("fflffl fflffl fflffl fflffl"))
	e.moveLines(-1, selectionClear)
	assertCaret(t, e, 0, 13, len("fflffl fflffl"))
	assertCaret(t, e, 0, 14, len("fflffl fflffl "))

	// Absurdly narrow constraints to force each ligature onto its own line.
	gtx.Constraints = layout.Exact(image.Pt(10, 10))