ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
61.11k stars 10.3k forks source link

Undo/Redo stack is not cleared when re-focusing the same InputText #3008

Closed elvissteinjr closed 4 years ago

elvissteinjr commented 4 years ago

Version/Branch of Dear ImGui:

Version: 1.74 Branch: master

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_win32.cpp + imgui_impl_dx11.cpp Compiler: MSVC19 Operating System: Windows 10

My Issue/Question:

If you type into an InputText (any variant), cancel by pressing ESC and then re-focus the input field (e.g. by clicking into it) again before any other InputText, the undo/redo stacks are preserved.

Apart from making wrong modifications, doing undos or redos in this state seems to be able to overwrite nearby memory or in the case of redo, trigger the assert at the top of STB_TEXTEDIT_INSERTCHARS().

Standalone, minimal, complete and verifiable example:

This issue can be observed in the demo code.

ocornut commented 4 years ago

Hello @elvissteinjr , Thanks for the report. This should be fixed now. We made the ESC revert operation undoable itself which seemed to be the least destructive design. So if you press ESC and then focus again and press Ctrl-Z this will essentially undo the revert.