Skip to content

Commit

Permalink
Use [NSCharacterSet newlineCharacterSet] to detect newline chars inst…
Browse files Browse the repository at this point in the history
…ead of just CR and LF
  • Loading branch information
rsms committed Dec 26, 2010
1 parent e4fb7bf commit ebacca0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/KTabContents.mm
Expand Up @@ -1273,6 +1273,7 @@ - (void)_updateLinesToRangesInfoForTextStorage:(NSTextStorage*)textStorage
// update linebreaks mapping
NSString *string = textStorage.string;

NSCharacterSet *newlines = [NSCharacterSet newlineCharacterSet];
BOOL editSpansToEndOfDocument =
(editedRange.location + editedRange.length == string.length);
size_t lbStartIndex = 0, lbEndIndex = 0, offsetRangesStart = 0;
Expand All @@ -1295,7 +1296,7 @@ - (void)_updateLinesToRangesInfoForTextStorage:(NSTextStorage*)textStorage

if (changeInLength == 1 && editedRange.length == 1) {
unichar ch = [string characterAtIndex:editedRange.location];
if (ch == '\n' || ch == '\r') {
if ([newlines characterIsMember:ch]) {
//DLOG("linebreak: inserted one explicitly");
NSUInteger lineStart, lineEnd, contentsEnd;
[string getLineStart:&lineStart
Expand Down

0 comments on commit ebacca0

Please sign in to comment.