From 0dc2885f3e0890585a0fa61a1ea041df9609b0ab Mon Sep 17 00:00:00 2001 From: ocornut Date: Sun, 22 Jun 2025 13:04:06 +0200 Subject: [PATCH] InputText: fix for InsertChars() to work on read-only buffer. (#8714, #8689, #8242) Ill defined feature but memory editor use InsertChars etc on a read-only buffer. `if (init_state)` block of InputTextEx() intentionally does not resize TextA, as unneeded. Amend b2c73596aeaf63b46b66a615ec02fce1b87f4248 Amend e900571 --- imgui_widgets.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 43d98bb88..d7214b6c2 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -4289,7 +4289,7 @@ void ImGuiInputTextCallbackData::InsertChars(int pos, const char* new_text, cons // Grow internal buffer if needed const bool is_resizable = (Flags & ImGuiInputTextFlags_CallbackResize) != 0; const int new_text_len = new_text_end ? (int)(new_text_end - new_text) : (int)ImStrlen(new_text); - if (new_text_len + BufTextLen + 1 > obj->TextA.Size) + if (new_text_len + BufTextLen + 1 > obj->TextA.Size && (Flags & ImGuiInputTextFlags_ReadOnly) == 0) { if (!is_resizable) return;