TCoolEdit: Undo is not working correctly
Borland's Object Windows Library for the modern age
Brought to you by:
jogybl,
sebas_ledesma
The bug may be in TCoolEdit::DeleteCharBack, in the line
This adds the character after the character that was deleted. Shouldn't it be
curPos.col - 1here?Alternatively, the conde in TUndoDeleteCharBack can be fixed to take the previous character, as it is called in two places.
Last edit: Ognyan Chernokozhev 2024-06-02
Checking the various code paths, the behavior is even worse if you try to undo the deletion of the CRLF between two lines, as it crashes the program.
Steps to repro:
Pushed a possible fix in [r6993] that seems to handle both undo cases - backspacing a charater in the middle of a line, and backspacing at the beginning of a line that joins it ti the previous line.
Related
Commit: [r6993]
Another Undo issue is that it doesn't work in overwrite mode:
Edit: This issue has now been fixed [r8136]. The fix has been merged into branches/7-coolprj-dev [r8137] (records svn:mergeinfo only; the bug was coincidentally fixed in [r7890] as part of undo/redo overhaul on this development branch).
Related
Commit: [r7890]
Commit: [r8136]
Commit: [r8137]
Last edit: Vidar Hasfjord 2025-07-29
This issue is fixed in branches/7-coolprj-dev .
@elotter wrote:
Which revision?
Hi @vattila,
these are the revisions related to the Undo/Redo implementation until I reported it:
[r7890]
CHG: Added a TUndoNode* to TUndoNode for general undoing of selection changes.
BUG: 'UndoSel' objects given to some TUndoNode derived classes are never deleted.
CHG: Typedef'd TRedoNode as TUndoNode to make TUndoNode usable as TRedoNode.
NEW: Added Redo() member to TUndoNode.
NEW: Implemented redo capability to TUndoInsertChar.
[r7891]
NEW: TUndoInsertChar accumulates subsequently entered keys, reducing the amout of TUndoInsertChar objects needed.
[r7892]
NEW: Implemented redo capability for TUndoDeleteSelection.
[r7893]
BUG: TUndoDeleteSelection.Redo() missed to supply new position.
NEW: TUndoPaste::Redo().
CHG: Moved the copying of selections to TCoolFileBuffer for reuse in TUndoPaste::Redo().
[r7894]
NEW: Redo() for TUndoKeyTab, TUndoKeyEnter, TUndoReplaceText classes.
[r7895]
NEW: TUndoKeyTabify::Redo().
[r7898]
BUG: Control-Delete didn't allow undoing selection deletion.
[r7902]
NEW: TUndoDeleteChar::Redo(), TUndoDeleteCharBack::Redo(), TUndoDeleteWord::Redo(), TUndoDeleteWordBack::Redo().
[r7903]
CHG: TUndoClearAll.Undo() restores selection.
NEW: TUndoClearAll.Redo().
[r7904]
CHG: TUndoDragDropMoveExt replaced by TUndoDeleteSelection.
[r7905]
CHG: TUndoDragDropCopy replaced by TUndoPaste, improved undoing of unselecting.
CHG: TUndoDragDropMove, TUndoDragDropCopy replaced by TUndoPaste.
[r7906]
CHG: TUndoNode::GetDescription(), TUndoNode::GetRedoDescription() create the descriptions now.
CHG: Removed the TRedoXXX classes.
CHG: Added missing Undo/Redo description strings.
[r7908]
BUG: TUndoPaste::Undo() did not clear the selection introduced by dropping external text.
Later there have been the following fixes and improvements:
[r7909]
NEW: One more TUndo class to fine-tune the selectioning on drag&drop text insertion.
[r7920]
BUG: TUndoDeleteSelection::Redo() missed to restore the selection before deleting it.
[r7930]
CHG: Optimized Undo/Redo description generation.
[r7932]
BUG: Undoing the deletion of a column selection in TUndoDeleteSelection::Undo() placed the restored selection incorrectly, when the selection was made from left to right.
[r7933]
CHG: Improved reconstruction of cursor position in TUndoDeleteLine.
[r7934]
CHG: Tab moves can't be undone any longer.
[r7938]
NEW: Added Undo/Redo to TCoolEdit::Untabify().
[r7950]
BUG: TUndoDeleteSelection::Redo() set the cursor position incorrect.
[r7965]
BUG: TUndoDeleteLine.Undo() did not restore the last character of a deleted line.
[r8029]
CHG: Postponed selection-redo in TUndoKeyUnTabSelection, TUndoKeyTabify and TUndoMoveLines until the core rodo is done to avoid debug exeptions due to selections beyond EOL.
[r8031]
NEW: Added TCoolEdit::Undo() and Redo().
CHG: Renamed
TUndoKeyTabify -> TUndoIndentSelection,
TUndoKeyUnTabSelection -> TUndoUnindentSelection.
[r8032]
CHG: Postponed selection-redo in TUndoPaste until the core rodo is done to avoid debug exeptions due to selections beyond EOL.
[r8042]
CHG: Made TUndoInsertChar handling inserted and overtyped characters in the same instance.
NEW: Nested TUndoInsertChar for multiple lines or carets.
[r8069]
CHG: TUndoInsertChar revised and simplified.
Related
Commit: [r7890]
Commit: [r7891]
Commit: [r7892]
Commit: [r7893]
Commit: [r7894]
Commit: [r7895]
Commit: [r7898]
Commit: [r7902]
Commit: [r7903]
Commit: [r7904]
Commit: [r7905]
Commit: [r7906]
Commit: [r7908]
Commit: [r7909]
Commit: [r7920]
Commit: [r7930]
Commit: [r7932]
Commit: [r7933]
Commit: [r7934]
Commit: [r7938]
Commit: [r7950]
Commit: [r7965]
Commit: [r8029]
Commit: [r8031]
Commit: [r8032]
Commit: [r8042]
Commit: [r8069]
@elotter wrote:
Super!
However, I have a hard time identifying fixes to issues that still apply to the trunk. In particular, the failure to undo inserted characters in overwrite mode (mentioned by me earlier in this ticket comment thread [#1df3]) is still an issue on the trunk, but has been fixed on the development branch. Can you guide me towards the revisions/code to look at?
Edit: After some investigation, I found that the bug was coincidentally fixed in [r7890] as part of undo/redo overhaul.
Same goes for any other issues with undo not working correctly on the trunk. The only other issue I can recall (apart from the unfinished column selection mode), is that undo doesn't restore the selection properly in all circumstances. It would be nice to make a minimal fix for this as well on the trunk, without rewriting the code, if possible.
Related
Commit: [r7890]
Last edit: Vidar Hasfjord 2025-07-29
Ah, sorry, I didn't realize that your question was specifically about this point.
Related
Commit: [r7890]
@elotter wrote:
No worries — its easy for key changes to get buried in big overhauls like this. It is tedious and hard to meticulously follow the Coding Standards and consistently link everything (revision to ticket, and from ticket to all relevant revisions). Remember that the revision log can be edited to fix typos, improve documentation and hook up everything (e.g. use TortoiseSVN's log view to edit). Considering you are unfamiliar with the tools and procedures, you are doing pretty well!
Now, regarding my earlier comment ("undo doesn't restore the selection properly in all circumstances [, and it] would be nice to make a minimal fix for this as well on the trunk"). Can it be done? Or does it depend on your comprehensive rewrite of the Undo functionality?
PS. And it is "trunk" (as in "trunk of a tree"), not "trunc" (as in "truncation"). :-)
Related
Wiki: Coding_Standards
Good to know. Although I use (Tortoise)Git for more than 20 years now as a backup tool, I never really needed the revision management, which seems to be much more powerful than I thought.
At first glance it looks easy to do. The base class TUndoNode should be untouched there.
With [r8229] and [r8350], the Undo and Redo functionality on the trunk has been completely redesigned and reimplemented. See [feature-requests:#266], and please review and test!
Related
Commit: [r8229]
Commit: [r8350]
Feature Requests: #266