oskusalerma/trelby — pull request #169 by anilgulecha (2012-06-08 15:45:47+00:00)
Title: Undo4

Another push for Undo. The difference since the last is simply:

```
--- a/src/finddlg.py
+++ b/src/finddlg.py
@@ -400,6 +400,8 @@ class FindDlg(wx.Dialog):

if diff != 0:
self.didReplaces = True
+ # create an undo point
+ self.ctrl.sp.utrack.noCheckUndo()

self.ctrl.sp.markChanged()
self.OnFind(autoFind = autoFind)
diff --git a/src/spellcheckdlg.py b/src/spellcheckdlg.py
index 4d56512..d6eb8e3 100644
--- a/src/spellcheckdlg.py
+++ b/src/spellcheckdlg.py
@@ -128,6 +128,10 @@ class SpellCheckDlg(wx.Dialog):

self.sc.col += len(self.sc.word) + diff
self.didReplaces = True
+
+ # create an undo point.
+ self.ctrl.sp.utrack.noCheckUndo()
+
self.ctrl.sp.markChanged()
self.gotoNext(False)
```

These create undo points at every word replace (both in find/replace, and in spellchecker). I decided against doing this for Delete elements, which to the user is a single unit of action, and thus, undo will undo this entire unit.

The behaviour of this can be funky though. Since reformatAll is called after the dialog closes (and not inside individual replaces when dialog is open), the last undo will undo the reformatted text, and then undo the text changes one by one.