From 6fc9337cd8ea192d9bc6c44201910342fd67d9aa Mon Sep 17 00:00:00 2001 From: PROP 65 <132837123+PROP65@users.noreply.github.com> Date: Sun, 7 May 2023 18:25:41 +0000 Subject: [PATCH] Update raygui.h (#279) fix for #278 --- src/raygui.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/raygui.h b/src/raygui.h index b81e71d..bfa7fd2 100644 --- a/src/raygui.h +++ b/src/raygui.h @@ -2229,8 +2229,12 @@ bool GuiTextBox(Rectangle bounds, char *text, int bufferSize, bool editMode) // Move backward text from cursor position for (int i = (textBoxCursorIndex - prevCodepointSize); i < textLength; i++) text[i] = text[i + prevCodepointSize]; - textBoxCursorIndex -= codepointSize; - textLength -= codepointSize; + // Prevent textBoxCursorIndex from decrementing past 0 + if(textBoxCursorIndex > 0) + { + textBoxCursorIndex -= codepointSize; + textLength -= codepointSize; + } // Make sure text last character is EOL text[textLength] = '\0';