From 804355fa54e1ddb328243e5341b6481e34f34e97 Mon Sep 17 00:00:00 2001 From: Nemirtingas Date: Sat, 3 Aug 2019 13:44:33 +0200 Subject: [PATCH] Fix input select going out of bound --- ImGui/imgui.cpp | 5 +++++ ImGui/imgui_widgets.cpp | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/ImGui/imgui.cpp b/ImGui/imgui.cpp index 3b9996a3..98346871 100644 --- a/ImGui/imgui.cpp +++ b/ImGui/imgui.cpp @@ -1700,6 +1700,11 @@ int ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const cha while (buf_out < buf_end-1 && (!in_text_end || in_text < in_text_end) && *in_text) { unsigned int c; + if (*in_text == 1) + { + in_text += 9; + continue; + } in_text += ImTextCharFromUtf8(&c, in_text, in_text_end); if (c == 0) break; diff --git a/ImGui/imgui_widgets.cpp b/ImGui/imgui_widgets.cpp index 1373ea74..a23486ab 100644 --- a/ImGui/imgui_widgets.cpp +++ b/ImGui/imgui_widgets.cpp @@ -3097,6 +3097,12 @@ static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const ImWchar* t if (c == '\r') continue; + if (*s == 1) + { + s += 9; + continue; + } + const float char_width = font->GetCharAdvance((ImWchar)c) * scale; line_width += char_width; }