Ticket UUID: | ab839efc5f783731a882c875cb7aa0a5cb690917 | |||
Title: | text edit undo: clearing text instead of restoring | |||
Type: | Bug | Version: | 8.6.10 and on | |
Submitter: | anonymous | Created on: | 2024-04-18 03:53:31 | |
Subsystem: | 18. [text] | Assigned To: | fvogel | |
Priority: | 5 Medium | Severity: | Important | |
Status: | Closed | Last Modified: | 2024-04-21 11:15:59 | |
Resolution: | Fixed | Closed By: | fvogel | |
Closed on: | 2024-04-21 11:15:59 | |||
Description: |
Tk 8.6.10+, Linux and Windows. Run the code snippet below, then
What??? The text has been cleared instead of restoring it. The worst of all is that after this you cannot restore the original text using undo/redo actions incl. Ctrl+Z and Ctrl+Shift+Z. The issue doesn't appear at:
or
The latter is nearly mystical.
| |||
User Comments: |
fvogel added on 2024-04-21 11:15:59:
Merged. fvogel added on 2024-04-20 10:14:24: Fixed, with a non-regression test added. See branch bug-ab839efc5f. Will merge soon (to the legacy text widget only). fvogel added on 2024-04-18 20:44:17: Basically, the fix is: Index: generic/tkText.c ================================================================== --- generic/tkText.c +++ generic/tkText.c @@ -5270,15 +5270,17 @@ if (objc != 3) { Tcl_WrongNumArgs(interp, 3, objv, NULL); return TCL_ERROR; } canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack); + TkUndoInsertUndoSeparator(textPtr->sharedTextPtr->undoStack); if (TextEditUndo(textPtr)) { Tcl_SetObjResult(interp, Tcl_NewStringObj("nothing to undo", -1)); Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_UNDO", NULL); return TCL_ERROR; } + TkUndoInsertUndoSeparator(textPtr->sharedTextPtr->undoStack); canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack); if (!canRedo || !canUndo) { GenerateUndoStackEvent(textPtr); } break; I believe [1669632] forgot to address this. fvogel added on 2024-04-18 20:03:13: Thanks for the report. I see what's happening and will fix this. Note to myself: this bug does not affect revised_text. |
