From d9b606672ae145457d12dacdc82b82c6ce9ebd79 Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 5 Jul 2021 17:48:19 +0200 Subject: [PATCH] InputText: Fix handling of paste failure (buffer full) which in some cases could corrupt the undo stack. (#4038) --- docs/CHANGELOG.txt | 2 ++ imstb_textedit.h | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index bb52ea04a..91a1a09bb 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -121,6 +121,8 @@ Other Changes: consistent with the compile-time default. (#3922) - DragScalar: Add default value for v_speed argument to match higher-level functions. (#3922) [@eliasdaler] - ColorEdit4: Alpha default to 255 (instead of 0) when omitted in hex input. (#3973) [@squadack] +- InputText: Fix handling of paste failure (buffer full) which in some cases could corrupt the undo stack. (#4038) + (fix submitted to https://github.com/nothings/stb/pull/1158) [@Unit2Ed, @ocornut] - InputText: Do not filter private unicode codepoints (e.g. icons) when pasted from clipboard. (#4005) [@dougbinks] - InputText: Align caret/cursor to pixel coordinates. (#4080) [@elvissteinjr] - InputText: Fixed CTRL+Arrow or OSX double-click leaking the presence of spaces when ImGuiInputTextFlags_Password diff --git a/imstb_textedit.h b/imstb_textedit.h index a82ead74e..2c635b27d 100644 --- a/imstb_textedit.h +++ b/imstb_textedit.h @@ -716,9 +716,11 @@ static int stb_textedit_paste_internal(STB_TEXTEDIT_STRING *str, STB_TexteditSta state->has_preferred_x = 0; return 1; } - // remove the undo since we didn't actually insert the characters - if (state->undostate.undo_point) - --state->undostate.undo_point; + // [DEAR IMGUI] + //// remove the undo since we didn't actually insert the characters + //if (state->undostate.undo_point) + // --state->undostate.undo_point; + // note: paste failure will leave deleted selection, may be restored with an undo (see https://github.com/nothings/stb/issues/734 for details) return 0; }