@@ -34,50 +34,24 @@ fileprivate extension String {
34
34
}
35
35
36
36
protocol TypewriterTextStorageDelegate : class {
37
- /// Like `textStorage(_:willProcessEditing:range:changeInLength:)` called
38
- /// before the actual processing begins.
39
- func typewriterTextStorageWillProcessEditing( _ typewriterTextStorage: TypewriterTextStorage )
40
-
41
- /// Called after `typewriterTextStorageDidEndEditing`, if `processEditing()`
42
- /// does emit that message.
43
- func typewriterTextStorageDidProcessEditing( _ typewriterTextStorage: TypewriterTextStorage )
44
-
45
- /// Called to notify about the end of `endEditing()`, or in case of an edit
46
- /// outside of a begin/end editing block, at the end of `processEditing()`
47
- /// but before `typewriterTextStorageDidProcessEditing(_:)`.
48
- func typewriterTextStorageDidEndEditing(
49
- _ typewriterTextStorage: TypewriterTextStorage ,
50
- butItReallyOnlyProcessedTheEdit endingAfterProcessing: Bool )
37
+ /// Called to notify about the end of `endEditing()`.
38
+ func typewriterTextStorageDidEndEditing( _ typewriterTextStorage: TypewriterTextStorage )
51
39
}
52
40
53
41
class TypewriterTextStorage : CustomTextStorageBase {
54
42
55
43
weak var typewriterDelegate : TypewriterTextStorageDelegate ?
56
44
57
- private var isBlockEditing = false
58
- private var wasBlockEditing = false
59
-
60
45
override func beginEditing( ) {
61
- isBlockEditing = true
62
46
super. beginEditing ( )
63
47
}
64
48
65
49
override func processEditing( ) {
66
- typewriterDelegate? . typewriterTextStorageWillProcessEditing ( self )
67
-
68
50
super. processEditing ( )
69
-
70
- if !wasBlockEditing { typewriterDelegate? . typewriterTextStorageDidEndEditing ( self , butItReallyOnlyProcessedTheEdit: true ) }
71
- wasBlockEditing = false
72
-
73
- typewriterDelegate? . typewriterTextStorageDidProcessEditing ( self )
74
51
}
75
52
76
53
override func endEditing( ) {
77
- // `super.endEditing()` triggers `processEditing`, so `wasBlockEditing` needs to be set first
78
- wasBlockEditing = isBlockEditing
79
- isBlockEditing = false
80
54
super. endEditing ( )
81
- typewriterDelegate? . typewriterTextStorageDidEndEditing ( self , butItReallyOnlyProcessedTheEdit : false )
55
+ typewriterDelegate? . typewriterTextStorageDidEndEditing ( self )
82
56
}
83
57
}
0 commit comments