From efec6ab1de4c25b22e38c53bb63087365d4f061b Mon Sep 17 00:00:00 2001 From: Nic Barker Date: Wed, 4 Dec 2024 16:02:53 +1300 Subject: [PATCH] Fix a bug that could cause double newlines in text blocks --- clay.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clay.h b/clay.h index d5bac1b..261ac99 100644 --- a/clay.h +++ b/clay.h @@ -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') { - previousWord = Clay__AddMeasuredWord(CLAY__INIT(Clay__MeasuredWord) { .startOffset = start, .length = length, .width = dimensions.width, .next = -1 }, previousWord); + 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;