@@ -1429,19 +1429,13 @@ static void _lb_offset_ranges(std::vector<NSRange> &lineToRangeVec,
14291429
14301430- (void )_updateLinesToRangesInfoForTextStorage : (NSTextStorage *)textStorage
14311431 inRange : (NSRange )editedRange
1432- changeDelta : (NSInteger )changeInLength {
1433- [self _updateLinesToRangesInfoForTextStorage: textStorage inRange: editedRange changeDelta: changeInLength recursed: NO ];
1434- }
1435-
1436- - (void )_updateLinesToRangesInfoForTextStorage : (NSTextStorage *)textStorage
1437- inRange : (NSRange )editedRange
1438- changeDelta : (NSInteger )changeInLength
1439- recursed : (BOOL )recursed {
1432+ changeDelta : (NSInteger )changeInLength
1433+ recursed : (BOOL )recursed {
14401434 // Note: We can't use a HSpinLock::Scope here since we need to release the
14411435 // lock before we call linesDidChangeWithLineCountDelta: at the end
14421436 lineToRangeSpinLock_.lock ();
14431437
1444-
1438+
14451439 // update linebreaks mapping
14461440 NSString *string = textStorage.string ;
14471441
@@ -1465,8 +1459,6 @@ - (void)_updateLinesToRangesInfoForTextStorage:(NSTextStorage*)textStorage
14651459 editSpansToEndOfDocument?@"YES":@"NO");
14661460 #endif
14671461 }
1468-
1469- DLOG (" len1: %d, len2: %d, affLines: %d" , changeInLength, editedRange.length , didAffectLines);
14701462
14711463 if (changeInLength == 1 && editedRange.length == 1 ) {
14721464 // simple use-case: inserted a single character at the end of a line
@@ -1540,7 +1532,7 @@ - (void)_updateLinesToRangesInfoForTextStorage:(NSTextStorage*)textStorage
15401532
15411533 offsetRangesStart = i;
15421534
1543- } else if (changeInLength < 0 ) {
1535+ } else if (changeInLength < 0 ) {
15441536 // edit action was "deletion"
15451537
15461538 if (didAffectLines) {
@@ -1571,7 +1563,7 @@ - (void)_updateLinesToRangesInfoForTextStorage:(NSTextStorage*)textStorage
15711563 }
15721564 }
15731565 }
1574-
1566+
15751567 // offset affected ranges
15761568 if (didAffectLines) {
15771569 // DLOG("_lb_offset_ranges(%lu, %ld)", offsetRangesStart, changeInLength);
@@ -1587,15 +1579,15 @@ - (void)_updateLinesToRangesInfoForTextStorage:(NSTextStorage*)textStorage
15871579 (lineToRangeVec_.size () != 0 || lineCountDelta != 0 )) {
15881580 [self linesDidChangeWithLineCountDelta: lineCountDelta];
15891581 }
1590-
1582+
15911583 // performing recursion like this solves problems with line numbering
15921584 // the idea being that the first time 'round we took care of vanishing text
15931585 // and on the second go we take care of the newly added text
15941586 if (changeInLength < 1 && recursed == NO ) {
1595- [self _updateLinesToRangesInfoForTextStorage: textStorage
1596- inRange: editedRange
1597- changeDelta: editedRange.length
1598- recursed: YES ];
1587+ [self _updateLinesToRangesInfoForTextStorage: textStorage
1588+ inRange: editedRange
1589+ changeDelta: editedRange.length
1590+ recursed: YES ];
15991591 }
16001592}
16011593
@@ -1627,12 +1619,14 @@ - (void)textStorageDidProcessEditing:(NSNotification *)notification {
16271619 if ([NSThread isMainThread ]) {
16281620 [self _updateLinesToRangesInfoForTextStorage: textStorage
16291621 inRange: editedRange
1630- changeDelta: changeInLength];
1622+ changeDelta: changeInLength
1623+ recursed: NO ];
16311624 } else {
16321625 K_DISPATCH_MAIN_ASYNC ({
16331626 [self _updateLinesToRangesInfoForTextStorage: textStorage
16341627 inRange: editedRange
1635- changeDelta: changeInLength];
1628+ changeDelta: changeInLength
1629+ recursed: NO ];
16361630 });
16371631 }
16381632
0 commit comments