From 97d62422f9620a8ae1e1e53fcf2985d99710c014 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Wed, 15 Sep 2021 15:44:17 +0200 Subject: [PATCH] Fix text input deletion --- imgui/src/input_widget.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/imgui/src/input_widget.rs b/imgui/src/input_widget.rs index 9c99169..5143683 100644 --- a/imgui/src/input_widget.rs +++ b/imgui/src/input_widget.rs @@ -288,8 +288,9 @@ where } }; - // it should always end with this \0. - if self.buf.ends_with('\0') { + // it should always end with one (or more if characters were deleted) + // null terminators + while self.buf.ends_with('\0') { self.buf.pop(); } @@ -386,8 +387,9 @@ impl<'ui, 'p, T: InputTextCallbackHandler, L: AsRef> InputTextMultiline<'ui ) }; - // it should always end with this \0. - if self.buf.ends_with('\0') { + // it should always end with one (or more if characters were deleted) + // null terminators + while self.buf.ends_with('\0') { self.buf.pop(); }