-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editing the buffer in InputTextCallback desyncs the undo/redo stack #4947
Comments
JoshuaWebb
added a commit
to JoshuaWebb/imgui
that referenced
this issue
Jan 27, 2022
Implement a function to update the undo/redo state for an `InputText` after a user callback has modified the buffer. This function is a bit weird in that it uses the wide string from the state for the old text and a utf8 buffer for the new text. It does this because these are the formats that are already available at the time we need them without requiring additional storage.
I've added a pull request (#4949) with the code I've used to fix this problem for myself in case that's useful. |
Thank you @JoshuaWebb and @nukeulater for those details and PR, will try to look soon. |
ocornut
added a commit
that referenced
this issue
Jun 7, 2022
…efore reactivating item. (#4947) + Metrics: Added "InputText" section.
I have pushed a first fix for the second issue (submitted by @nukeulater) which is a different one than the first one (fixed by #4949). The fix include a new tool in Metrics to visualize the undo state: |
ocornut
pushed a commit
that referenced
this issue
Jun 8, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version/Branch of Dear ImGui:
Version: 1.87
Branch: master
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_win32.cpp + imgui_impl_dx11.cpp (although it doesn't actually matter for this bug)
Operating System: Windows 10
My Issue/Question:
Editing an
InputText
viaImGuiInputTextCallbackData
doesn't register any entries in the undo/redo stack.Screenshots/Video
Repro steps:
main.cpp
Input
Replacement
Input
to replaceCtrl+R
to trigger the replacement callbackCtrl+Z
(Undo) once. The input text is now incorrect, and the cursor is wrong.Ctrl+Y
(Redo) once. The application crashes with an assertion(Assertion failed: pos <= text_len, file ..\..\imgui_widgets.cpp, line 3667)
Standalone, minimal, complete and verifiable example:
The text was updated successfully, but these errors were encountered: