Skip to content

Commit

Permalink
Fix RTL and last character cursor selection state bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
tonisevener committed Dec 12, 2023
1 parent d4a4c28 commit bc00a5a
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions Components/Sources/ComponentsObjC/WKSourceEditorFormatterHeading.m
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,33 @@ - (BOOL)attributedString:(NSMutableAttributedString *)attributedString isContent

if (attrs[contentKey] != nil) {
isContentKey = YES;
} else {
// Edge case, check previous character if we are up against closing string
if (attrs[WKSourceEditorCustomKeyColorOrange]) {
attrs = [attributedString attributesAtIndex:range.location - 1 effectiveRange:nil];
if (attrs[contentKey] != nil) {
isContentKey = YES;
}
}
}
}

} else {
__block NSRange unionRange = NSMakeRange(NSNotFound, 0);
[attributedString enumerateAttributesInRange:range options:nil usingBlock:^(NSDictionary<NSAttributedStringKey,id> * _Nonnull attrs, NSRange loopRange, BOOL * _Nonnull stop) {
if ((attrs[contentKey] != nil) &&
(loopRange.location == range.location && loopRange.length == range.length)) {
isContentKey = YES;
if (attrs[contentKey] != nil) {
if (unionRange.location == NSNotFound) {
unionRange = loopRange;
} else {
unionRange = NSUnionRange(unionRange, loopRange);
}
stop = YES;
}
}];

if (NSEqualRanges(unionRange, range)) {
isContentKey = YES;
}
}

return isContentKey;
Expand Down

0 comments on commit bc00a5a

Please sign in to comment.