@@ -133,8 +133,8 @@ - (void)removeTypingAttributes {
133133- (BOOL )handleBackspaceInRange : (NSRange )range replacementText : (NSString *)text {
134134 if (
135135 [self detectStyle: _input->textView.selectedRange] &&
136- NSEqualRanges (_input->textView.selectedRange, NSMakeRange (0 , 0 )) &&
137- [text isEqualToString:@""]
136+ NSEqualRanges (_input->textView.selectedRange, NSMakeRange (0 , 0 )) &&
137+ [text isEqualToString:@""]
138138 ) {
139139 // removing first list point by backspacing doesn't remove typing attributes because it doesn't run textViewDidChange
140140 // so we try guessing that a point should be deleted here
@@ -204,22 +204,11 @@ - (BOOL)detectStyle:(NSRange)range {
204204 }
205205 ];
206206 } else {
207- NSInteger searchLocation = range.location ;
208- if (searchLocation == _input->textView .textStorage .length ) {
209- NSParagraphStyle *pStyle = _input->textView .typingAttributes [NSParagraphStyleAttributeName ];
210- return [self styleCondition: pStyle :NSMakeRange (0 , 0 )];
211- }
212-
213- NSRange paragraphRange = NSMakeRange (0 , 0 );
214- NSRange inputRange = NSMakeRange (0 , _input->textView .textStorage .length );
215- NSParagraphStyle *paragraph = [_input->textView.textStorage
216- attribute: NSParagraphStyleAttributeName
217- atIndex: searchLocation
218- longestEffectiveRange: ¶graphRange
219- inRange: inputRange
207+ return [OccurenceUtils detect: NSParagraphStyleAttributeName withInput: _input atIndex: range.location checkPrevious: YES
208+ withCondition: ^BOOL (id _Nullable value, NSRange range) {
209+ return [self styleCondition: value :range];
210+ }
220211 ];
221-
222- return [self styleCondition: paragraph :NSMakeRange (0 , 0 )];
223212 }
224213}
225214
0 commit comments