From 21dc297c28f53ae28a1d3e28a33b73c4a09c28c9 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 5 Sep 2024 16:28:24 +0200 Subject: [PATCH] InputText: amends: remove TextAIsValid. (7925) --- imgui_internal.h | 1 - imgui_widgets.cpp | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/imgui_internal.h b/imgui_internal.h index dca3d64573510..2aa0b51b73b8d 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1130,7 +1130,6 @@ struct IMGUI_API ImGuiInputTextState int CurLenA; // UTF-8 length of the string in TextA (in bytes) ImVector TextA; // temporary UTF8 buffer for callbacks and other operations. this is not updated in every code-path! size=capacity. ImVector InitialTextA; // value to revert to when pressing Escape = backup of end-user buffer at the time of focus (in UTF-8, unaltered) - bool TextAIsValid; // temporary UTF8 buffer is not initially valid before we make the widget active (until then we pull the data from user argument) int BufCapacityA; // end-user buffer capacity ImVec2 Scroll; // horizontal offset (managed manually) + vertical scrolling (pulled from child window's own Scroll.y) ImStb::STB_TexteditState Stb; // state for stb_textedit.h diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index e6173d1a1a479..e840744dd5a04 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -4447,13 +4447,12 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ // Preserve cursor position and undo/redo stack if we come back to same widget // FIXME: Since we reworked this on 2022/06, may want to differentiate recycle_cursor vs recycle_undostate? bool recycle_state = (state->ID == id && !init_changed_specs && !init_reload_from_user_buf); - if (recycle_state && (state->CurLenA != buf_len || (state->TextAIsValid && strncmp(state->TextA.Data, buf, buf_len) != 0))) + if (recycle_state && (state->CurLenA != buf_len || (strncmp(state->TextA.Data, buf, buf_len) != 0))) recycle_state = false; // Start edition state->ID = id; state->TextA.resize(buf_size + 1); // we use +1 to make sure that .Data is always pointing to at least an empty string. - state->TextAIsValid = true; state->CurLenA = (int)strlen(buf); memcpy(state->TextA.Data, buf, state->CurLenA + 1); @@ -4538,7 +4537,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ bool validated = false; // Select the buffer to render. - const bool buf_display_from_state = (render_cursor || render_selection || g.ActiveId == id) && !is_readonly && state && state->TextAIsValid; + const bool buf_display_from_state = (render_cursor || render_selection || g.ActiveId == id) && !is_readonly && state; const bool is_displaying_hint = (hint != NULL && (buf_display_from_state ? state->TextA.Data : buf)[0] == 0); // Password pushes a temporary font with only a fallback glyph