Browse Source

ImGuiTextBuffer: Fix size() to allow using ImGuiTextBuffer with resize(0) patterns.

omar 6 years ago
parent
commit
d93e3c17fc
1 changed files with 1 additions and 1 deletions
  1. 1 1
      imgui.h

+ 1 - 1
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); }