From d93e3c17fc7e0da618ac8cf4396af91c7459d8a4 Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 5 Feb 2019 13:13:35 +0100 Subject: [PATCH] ImGuiTextBuffer: Fix size() to allow using ImGuiTextBuffer with resize(0) patterns. --- imgui.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui.h b/imgui.h index a5c48597..3d565462 100644 --- a/imgui.h +++ b/imgui.h @@ -1583,7 +1583,7 @@ struct ImGuiTextBuffer inline char operator[](int i) { IM_ASSERT(Buf.Data != NULL); return Buf.Data[i]; } const char* begin() const { return Buf.Data ? &Buf.front() : EmptyString; } const char* end() const { return Buf.Data ? &Buf.back() : EmptyString; } // Buf is zero-terminated, so end() will point on the zero-terminator - int size() const { return Buf.Data ? Buf.Size - 1 : 0; } + int size() const { return Buf.Size ? Buf.Size - 1 : 0; } bool empty() { return Buf.Size <= 1; } void clear() { Buf.clear(); } void reserve(int capacity) { Buf.reserve(capacity); }