Fix a bug that could cause double newlines in text blocks

This commit is contained in:
Nic Barker 2024-12-04 16:02:53 +13:00
parent 9f0cf751da
commit efec6ab1de

2
clay.h
View File

@ -1639,7 +1639,9 @@ Clay__MeasureTextCacheItem *Clay__MeasureTextCached(Clay_String *text, Clay_Text
previousWord = Clay__AddMeasuredWord(CLAY__INIT(Clay__MeasuredWord) { .startOffset = start, .length = length + 1, .width = dimensions.width, .next = -1 }, previousWord);
}
if (current == '\n') {
if (length > 1) {
previousWord = Clay__AddMeasuredWord(CLAY__INIT(Clay__MeasuredWord) { .startOffset = start, .length = length, .width = dimensions.width, .next = -1 }, previousWord);
}
previousWord = Clay__AddMeasuredWord(CLAY__INIT(Clay__MeasuredWord) { .startOffset = end + 1, .length = 0, .width = 0, .next = -1 }, previousWord);
}
measuredWidth += dimensions.width;