Skip to content
Snippets Groups Projects
Commit 46fe3ca0 authored by George Nachman's avatar George Nachman
Browse files

Fix a bug where coords and content would not be in 1:1 correspondence when an...

Fix a bug where coords and content would not be in 1:1 correspondence when an url action is found and hard newlines are ignored (set by an advanced pref, which is not the default setting). Remove the corresponding coords as well as the newlines from the string. Issue 5929.
parent 756ed28d
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -212,6 +212,10 @@ int decode_utf8_char(const unsigned char * restrict datap,
NSString *complexString,
BOOL *stop))block;
 
// It is safe to modify, delete, or insert characters in `range` within `block`.
- (void)reverseEnumerateSubstringsEqualTo:(NSString *)query
block:(void (^)(NSRange range))block;
- (NSUInteger)iterm_unsignedIntegerValue;
 
// Returns modified attributes for drawing self fitting size within one point.
Loading
Loading
Loading
Loading
@@ -1514,6 +1514,15 @@ static TECObjectRef CreateTECConverterForUTF8Variants(TextEncodingVariant varian
} while (NSMaxRange(range) < self.length);
}
 
- (void)reverseEnumerateSubstringsEqualTo:(NSString *)query
block:(void (^)(NSRange range))block {
NSRange range = [self rangeOfString:query options:NSBackwardsSearch];
while (range.location != NSNotFound) {
block(range);
range = [self rangeOfString:query options:NSBackwardsSearch range:NSMakeRange(0, range.location)];
}
}
- (NSUInteger)iterm_unsignedIntegerValue {
NSScanner *scanner = [NSScanner scannerWithString:self];
unsigned long long ull;
Loading
Loading
Loading
Loading
@@ -1589,7 +1589,16 @@ const NSInteger kLongMaximumWordLength = 100000;
continuationChars:continuationChars
coords:coords];
if (!respectHardNewlines) {
content = [content stringByReplacingOccurrencesOfString:@"\n" withString:@""];
if (coords == nil) {
content = [content stringByReplacingOccurrencesOfString:@"\n" withString:@""];
} else {
NSMutableString *mutableContent = [[content mutableCopy] autorelease];
[content reverseEnumerateSubstringsEqualTo:@"\n" block:^(NSRange range) {
[mutableContent replaceCharactersInRange:range withString:@""];
[coords removeObjectsInRange:range];
}];
content = mutableContent;
}
}
return content;
}
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment