mirror of
https://github.com/ocornut/imgui.git
synced 2025-10-16 06:55:59 +00:00
InputText: fixed an infinite loop error happening if a custom input text callback modifies/clear BufTextLen before calling InsertChars(). (#8994, #3237)
+ misc comments.
This commit is contained in:
@@ -3941,6 +3941,7 @@ static ImVec2 InputTextCalcTextSize(ImGuiContext* ctx, const char* text_begin, c
|
||||
{
|
||||
ImGuiContext& g = *ctx;
|
||||
ImGuiInputTextState* obj = &g.InputTextState;
|
||||
IM_ASSERT(text_end_display >= text_begin && text_end_display <= text_end);
|
||||
return ImFontCalcTextSizeEx(g.Font, g.FontSize, FLT_MAX, obj->WrapWidth, text_begin, text_end_display, text_end, out_remaining, out_offset, flags);
|
||||
}
|
||||
|
||||
@@ -4321,11 +4322,12 @@ void ImGuiInputTextCallbackData::InsertChars(int pos, const char* new_text, cons
|
||||
memcpy(Buf + pos, new_text, (size_t)new_text_len * sizeof(char));
|
||||
Buf[BufTextLen + new_text_len] = '\0';
|
||||
|
||||
if (CursorPos >= pos)
|
||||
CursorPos += new_text_len;
|
||||
SelectionStart = SelectionEnd = CursorPos;
|
||||
BufDirty = true;
|
||||
BufTextLen += new_text_len;
|
||||
if (CursorPos >= pos)
|
||||
CursorPos += new_text_len;
|
||||
CursorPos = ImClamp(CursorPos, 0, BufTextLen);
|
||||
SelectionStart = SelectionEnd = CursorPos;
|
||||
}
|
||||
|
||||
void ImGui::PushPasswordFont()
|
||||
|
Reference in New Issue
Block a user