Don't crash on narrow window widths (#74365)

This commit is contained in:
Ian Hickson
2021-01-25 11:39:45 -08:00
committed by GitHub
parent b400534dc7
commit 5d8dfa44b6
2 changed files with 96 additions and 17 deletions

View File

@@ -248,5 +248,78 @@ needs to be wrapped.
01234567890123456789012345678901234567
890123456789'''));
});
testWithoutContext('', () {
expect(wrapText(
' ' * 7 + 'abc def ghi', columnWidth: 20, hangingIndent: 5, indent: 3, shouldWrap: true),
equals(
' abc def\n'
' ghi'
),
);
expect(wrapText(
'abc def ghi', columnWidth: 0, hangingIndent: 5, shouldWrap: true),
equals(
'abc def\n'
'ghi'
),
);
expect(wrapText(
'abc def ghi', columnWidth: 0, indent: 5, shouldWrap: true),
equals(
'abc def\n'
'ghi'
),
);
expect(wrapText(
' abc def ghi', columnWidth: 0, shouldWrap: true),
equals(
'abc def\n'
'ghi'
),
);
expect(wrapText(
'abc def ghi', columnWidth: kMinColumnWidth - 2, hangingIndent: 5, shouldWrap: true),
equals(
'abc def\n'
'ghi'
),
);
expect(wrapText(
'abc def ghi', columnWidth: kMinColumnWidth - 2, indent: 5, shouldWrap: true),
equals(
'abc def\n'
'ghi'
),
);
expect(wrapText(
' abc def ghi', columnWidth: kMinColumnWidth - 2, shouldWrap: true),
equals(
'abc def\n'
'ghi'
),
);
expect(wrapText(
'abc def ghi jkl', columnWidth: kMinColumnWidth + 2, hangingIndent: 5, shouldWrap: true),
equals(
'abc def ghi\n'
' jkl'
),
);
expect(wrapText(
'abc def ghi', columnWidth: kMinColumnWidth + 2, indent: 5, shouldWrap: true),
equals(
' abc def\n'
' ghi'
),
);
expect(wrapText(
' abc def ghi', columnWidth: kMinColumnWidth + 2, shouldWrap: true),
equals(
' abc def\n'
' ghi'
),
);
});
});
}