diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index ae3eb97bc..8fabf7964 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -86,7 +86,8 @@ Other Changes: for vertical scrollbar range would be +1 when the widget is inactive, word-wrap is disabled and the text buffer ends with '\n'. Fixed a similar issue related to clipping large amount of text. - - InputTextMultiline: avoid going through reactivation code when activating scrollbar. + - InputTextMultiline: avoid going through reactivation code and fixed losing revert value + when activating scrollbar. - Style: - Border sizes are now scaled (and rounded) by ScaleAllSizes(). - When using large values with ScallAllSizes(), the following items thickness diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 096b3f94d..8898e69ae 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -4806,8 +4806,11 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ // From the moment we focused we are normally ignoring the content of 'buf' (unless we are in read-only mode) const int buf_len = (int)ImStrlen(buf); IM_ASSERT(((buf_len + 1 <= buf_size) || (buf_len == 0 && buf_size == 0)) && "Is your input buffer properly zero-terminated?"); - state->TextToRevertTo.resize(buf_len + 1); // UTF-8. we use +1 to make sure that .Data is always pointing to at least an empty string. - memcpy(state->TextToRevertTo.Data, buf, buf_len + 1); + if (!user_scroll_finish) + { + state->TextToRevertTo.resize(buf_len + 1); // UTF-8. we use +1 to make sure that .Data is always pointing to at least an empty string. + memcpy(state->TextToRevertTo.Data, buf, buf_len + 1); + } // 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?