Skip to content

Commit 09be5ab

Browse files
committed
fix: make insertion util use only current typing attributes
1 parent e6f4cd1 commit 09be5ab

1 file changed

Lines changed: 1 addition & 12 deletions

File tree

ios/utils/TextInsertionUtils.mm

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,7 @@
55

66
@implementation TextInsertionUtils
77
+ (void)insertText:(NSString*)text inView:(UITextView*)textView at:(NSInteger)index additionalAttributes:(NSDictionary<NSAttributedStringKey, id>*)additionalAttrs {
8-
NSMutableDictionary<NSAttributedStringKey, id> *copiedAttrs = [[NSMutableDictionary<NSAttributedStringKey, id> alloc ] init];
9-
if(index == textView.textStorage.length) {
10-
if(index > 0) {
11-
// if we are at the end of the text, we want to use previous style, but only if the index won't be -1 then
12-
copiedAttrs = [textView.textStorage attributesAtIndex:index - 1 effectiveRange:nullptr].mutableCopy;
13-
}
14-
} else {
15-
copiedAttrs = [textView.textStorage attributesAtIndex:index effectiveRange:nullptr].mutableCopy;
16-
}
17-
if([copiedAttrs count] == 0) {
18-
copiedAttrs = textView.typingAttributes.mutableCopy;
19-
}
8+
NSMutableDictionary<NSAttributedStringKey, id> *copiedAttrs = [textView.typingAttributes mutableCopy];
209
if(additionalAttrs != nullptr) {
2110
[copiedAttrs addEntriesFromDictionary: additionalAttrs];
2211
}

0 commit comments

Comments
 (0)