kolinkrewinkel / Multiplex

Simultaneous editing for Xcode, inspired by Sublime Text.
MIT License
283 stars 10 forks source link

-scrollViewDidScroll: called during selection change triggers -setSelectedRange: crash #21

Closed kolinkrewinkel closed 9 years ago

kolinkrewinkel commented 9 years ago
Application Specific Information:
NSViewBoundsDidChangeNotification
ProductBuildVersion: 7A1001
ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/DVTFrameworks/DVTFrameworks-8208/DVTKit/TextCompletion/DVTCompletingTextView.m:1211
Details:  Attempt to select an invalid range of text: {10426, 1278}. Text length: 10433. (Please file a Radar. OK to Continue from here.)
Object:   <DVTSourceTextView: 0x7fbac966b1f0>
Method:   -setSelectedRange:
Thread:   <NSThread: 0x7fbac36197c0>{number = 1, name = main}
Hints:   None
Backtrace:
  0  0x0000000111084904 -[IDEAssertionHandler handleFailureInMethod:object:fileName:lineNumber:assertionSignature:messageFormat:arguments:] (in IDEKit)
  1  0x000000010fc4e22e _DVTAssertionHandler (in DVTFoundation)
  2  0x000000010fc4e445 _DVTAssertionFailureHandler (in DVTFoundation)
  3  0x00000001101073da -[DVTCompletingTextView setSelectedRange:] (in DVTKit)
  4  0x000000011012dbac -[DVTSourceTextView setSelectedRange:] (in DVTKit)
  5  0x00007fff8d07a835 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] (in Foundation)
  6  0x00007fff8d1eb843 _NSSetRangeValueAndNotify (in Foundation)
  7  0x000000011c861ac3 -[MPXTextViewSelectionDecorator updateTextViewSelectedRange] at /Users/kolin/Multiplex/Multiplex/Modules/MPXSelectionCore/MPXSelectionCore/MPXTextViewSelectionDecorator.m:159 (in MPXSelectionCore)
  8  0x000000011c8616ba -[MPXTextViewSelectionDecorator scrollViewDidScroll:] at /Users/kolin/Multiplex/Multiplex/Modules/MPXSelectionCore/MPXSelectionCore/MPXTextViewSelectionDecorator.m:154 (in MPXSelectionCore)
  9  0x00007fff90388c9c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ (in CoreFoundation)
 10  0x00007fff90388c2f ___CFXRegistrationPost_block_invoke (in CoreFoundation)
 11  0x00007fff90388ba7 _CFXRegistrationPost (in CoreFoundation)
 12  0x00007fff90388912 ___CFXNotificationPost_block_invoke (in CoreFoundation)
 13  0x00007fff903456d2 -[_CFXNotificationRegistrar find:object:observer:enumerator:] (in CoreFoundation)
 14  0x00007fff90344925 _CFXNotificationPost (in CoreFoundation)
 15  0x00007fff8d07a0fa -[NSNotificationCenter postNotificationName:object:userInfo:] (in Foundation)
 16  0x000000010fc280c8 -[NSNotificationCenter(DVTNSNotificationCenterAdditions) _dvt_postNotificationName:object:userInfo:] (in DVTFoundation)
 17  0x00007fff958ad0fd -[NSView _postBoundsChangeNotification] (in AppKit)
 18  0x00007fff958acfe2 -[NSView translateOriginToPoint:] (in AppKit)
 19  0x00007fff958abbbc -[NSClipView _immediateScrollToPoint:] (in AppKit)
 20  0x00007fff958aac64 -[NSClipView scrollToPoint:] (in AppKit)
 21  0x00007fff958e8678 -[NSScrollView scrollClipView:toPoint:] (in AppKit)
 22  0x00007fff9588fd83 -[NSClipView _scrollTo:animateScroll:flashScrollerKnobs:] (in AppKit)
 23  0x00007fff9588f511 -[NSClipView _reflectDocumentViewFrameChange] (in AppKit)
 24  0x00007fff957ec5b2 -[NSView _postFrameChangeNotification] (in AppKit)
 25  0x00007fff957e7373 -[NSView setFrameSize:] (in AppKit)
 26  0x00007fff95888ea4 -[NSTextView(NSPrivate) _setFrameSize:forceScroll:] (in AppKit)
 27  0x00007fff95888b7c -[NSTextView setFrameSize:] (in AppKit)
 28  0x000000011012ecaa -[DVTSourceTextView setFrameSize:] (in DVTKit)
 29  0x00007fff958881af -[NSTextView setConstrainedFrameSize:] (in AppKit)
 30  0x00007fff94cabeaa -[NSLayoutManager(NSPrivate) _resizeTextViewForTextContainer:] (in UIFoundation)
 31  0x00007fff94bc9192 -[NSLayoutManager textStorage:edited:range:changeInLength:invalidatedRange:] (in UIFoundation)
 32  0x00000001102903d6 -[DVTFoldingLayoutManager textStorage:edited:range:changeInLength:invalidatedRange:] (in DVTKit)
 33  0x00007fff94bc9204 -[NSLayoutManager processEditingForTextStorage:edited:range:changeInLength:invalidatedRange:] (in UIFoundation)
 34  0x00007fff94c11e80 -[NSTextStorage _notifyEdited:range:changeInLength:invalidatedRange:] (in UIFoundation)
 35  0x00007fff94c1195e -[NSTextStorage processEditing] (in UIFoundation)
 36  0x00000001101124db -[DVTTextStorage processEditing] (in DVTKit)
 37  0x00007fff94c11593 -[NSTextStorage endEditing] (in UIFoundation)
 38  0x000000011011219d -[DVTTextStorage endEditing] (in DVTKit)
 39  0x00007fff9596acbc -[NSTextView insertText:replacementRange:] (in AppKit)
 40  0x0000000110163530 -[DVTCompletingTextView insertText:replacementRange:] (in DVTKit)
 41  0x000000011c8390a3 __57-[DVTSourceTextView(MPXEditorExtensions) deleteBackward:]_block_invoke at /Users/kolin/Multiplex/Multiplex/Categories/DVTSourceTextView+MPXEditorExtensions.m:250 (in Multiplex)
 42  0x000000011c85eb27 -[MPXSelectionManager mapSelectionsWithMovementDirection:modifyingSelections:usingBlock:] at /Users/kolin/Multiplex/Multiplex/Modules/MPXSelectionCore/MPXSelectionCore/MPXSelectionManager.m:228 (in MPXSelectionCore)
 43  0x000000011c8386bd -[DVTSourceTextView(MPXEditorExtensions) deleteBackward:] at /Users/kolin/Multiplex/Multiplex/Categories/DVTSourceTextView+MPXEditorExtensions.m:248 (in Multiplex)
 44  0x00007fff9598ad6f -[NSTextView doCommandBySelector:] (in AppKit)
 45  0x000000011016fd5c -[DVTCompletingTextView doCommandBySelector:] (in DVTKit)
 46  0x00007fff9598ac86 -[NSTextInputContext(NSInputContext_WithCompletion) doCommandBySelector:completionHandler:] (in AppKit)
 47  0x00007fff959669a1 -[NSKeyBindingManager(NSKeyBindingManager_MultiClients) interpretEventAsCommand:forClient:] (in AppKit)
 48  0x00007fff95970027 __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke978 (in AppKit)
 49  0x00007fff9598ab46 __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke_3 (in AppKit)
 50  0x00007fff9596fe99 -[NSTextInputContext tryHandleEvent_HasMarkedText_withDispatchCondition:dispatchWork:continuation:] (in AppKit)
 51  0x00007fff9596fe23 __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke966 (in AppKit)
 52  0x00007fff9653ff55 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_5 (in HIToolbox)
 53  0x00007fff9653eedd ___ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec_block_invoke (in HIToolbox)
 54  0x00007fff959691d4 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke176 (in AppKit)
 55  0x00007fff959685b4 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke_2 (in AppKit)
 56  0x00007fff95968527 -[NSTextInputContext tryHandleTSMEvent_HasMarkedText_withDispatchCondition:dispatchWork:continuation:] (in AppKit)
 57  0x00007fff95968217 -[NSTextInputContext handleTSMEvent:completionHandler:] (in AppKit)
 58  0x00007fff95967546 _NSTSMEventHandler (in AppKit)
 59  0x00007fff964e798e DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) (in HIToolbox)
 60  0x00007fff964e6e18 SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) (in HIToolbox)
 61  0x00007fff964e6c7b SendEventToEventTargetWithOptions (in HIToolbox)
 62  0x00007fff9653c319 SendTSMEvent_WithCompletionHandler (in HIToolbox)
 63  0x00007fff9653c808 __SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler_block_invoke (in HIToolbox)
 64  0x00007fff9653c65b __SendFilterTextEvent_WithCompletionHandler_block_invoke (in HIToolbox)
 65  0x00007fff9653c369 SendTSMEvent_WithCompletionHandler (in HIToolbox)
 66  0x00007fff9653c14b SendFilterTextEvent_WithCompletionHandler (in HIToolbox)
 67  0x00007fff9653be24 SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler (in HIToolbox)
 68  0x00007fff9653bbd4 __utDeliverTSMEvent_WithCompletionHandler_block_invoke_2 (in HIToolbox)
 69  0x00007fff9653ba78 __utDeliverTSMEvent_WithCompletionHandler_block_invoke (in HIToolbox)
 70  0x00007fff9653b86c TSMKeyEvent_WithCompletionHandler (in HIToolbox)
 71  0x00007fff9653b562 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_4 (in HIToolbox)
 72  0x00007fff9653b3cc __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_3 (in HIToolbox)
 73  0x00007fff9653b10a __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_2 (in HIToolbox)
 74  0x00007fff9653aecf __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke (in HIToolbox)
 75  0x00007fff9653a576 TSMProcessRawKeyEventWithOptionsAndCompletionHandler (in HIToolbox)
 76  0x00007fff959673f7 __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke955 (in AppKit)
 77  0x00007fff959660d9 -[NSTextInputContext tryTSMProcessRawKeyEvent:dispatchCondition:setupForDispatch:furtherCondition:dispatchWork:continuation:] (in AppKit)
 78  0x00007fff95965dd3 -[NSTextInputContext _handleEvent:options:completionHandler:] (in AppKit)
 79  0x00007fff959658a6 -[NSTextInputContext handleEvent:] (in AppKit)
 80  0x00007fff959657af -[NSView interpretKeyEvents:] (in AppKit)
 81  0x00007fff959655da -[NSTextView keyDown:] (in AppKit)
 82  0x00007fff95f88b79 -[NSWindow _reallySendEvent:isDelayedEvent:] (in AppKit)
 83  0x00007fff959cdb8d -[NSWindow sendEvent:] (in AppKit)
 84  0x00000001110ab31e -[IDEWorkspaceWindow sendEvent:] (in IDEKit)
 85  0x00007fff9594e259 -[NSApplication sendEvent:] (in AppKit)
 86  0x0000000110e61ae9 -[IDEApplication sendEvent:] (in IDEKit)
 87  0x00007fff957b4d9a -[NSApplication run] (in AppKit)
 88  0x00007fff9577dfbe NSApplicationMain (in AppKit)
 89  0x00007fff9c4c15ad start (in libdyld.dylib)

abort() called

Application Specific Signatures:
0

Global Trace Buffer (reverse chronological seconds):
57.004915    CFNetwork                  0x00007fff99968163 TCP Conn 0x7fbac875bf40 SSL Handshake DONE
57.475118    CFNetwork                  0x00007fff9996803f TCP Conn 0x7fbac875bf40 starting SSL negotiation
57.475298    CFNetwork                  0x00007fff99966a0f TCP Conn 0x7fbac875bf40 complete. fd: 44, err: 0
57.475489    CFNetwork                  0x00007fff999f51ad TCP Conn 0x7fbac875bf40 event 1. err: 0
58.954685    CFNetwork                  0x00007fff99965cdf TCP Conn 0x7fbac875bf40 started
59.012332    CFNetwork                  0x00007fff9992989e Creating default cookie storage with process/bundle identifier
59.012332    CFNetwork                  0x00007fff99929836 Faulting in CFHTTPCookieStorage singleton
59.012332    CFNetwork                  0x00007fff999296c5 Faulting in NSHTTPCookieStorage singleton
59.015233    CFNetwork                  0x00007fff99a26d38 NSURLConnection finished with error - code -1100

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff9f7950ae __pthread_kill + 10
1   libsystem_pthread.dylib         0x00007fff9c7ef500 pthread_kill + 90
2   libsystem_c.dylib               0x00007fff9baeb37b abort + 129
3   com.apple.dt.IDEKit             0x00000001110844fb +[IDEAssertionHandler _handleAssertionWithLogString:assertionSignature:assertionReason:extraBacktrace:] + 1481
4   com.apple.dt.IDEKit             0x0000000111084adb -[IDEAssertionHandler handleFailureInMethod:object:fileName:lineNumber:assertionSignature:messageFormat:arguments:] + 1202
5   com.apple.dt.DVTFoundation      0x000000010fc4e22e _DVTAssertionHandler + 562
6   com.apple.dt.DVTFoundation      0x000000010fc4e445 _DVTAssertionFailureHandler + 407
7   com.apple.dt.DVTKit             0x00000001101073da -[DVTCompletingTextView setSelectedRange:] + 182
8   com.apple.dt.DVTKit             0x000000011012dbac -[DVTSourceTextView setSelectedRange:] + 52
9   com.apple.Foundation            0x00007fff8d07a835 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] + 1049
10  com.apple.Foundation            0x00007fff8d1eb843 _NSSetRangeValueAndNotify + 286
11  com.kolinkrewinkel.MPXSelectionCore 0x000000011c861ac3 -[MPXTextViewSelectionDecorator updateTextViewSelectedRange] + 1011 (MPXTextViewSelectionDecorator.m:169)
12  com.kolinkrewinkel.MPXSelectionCore 0x000000011c8616ba -[MPXTextViewSelectionDecorator scrollViewDidScroll:] + 58 (MPXTextViewSelectionDecorator.m:156)
13  com.apple.CoreFoundation        0x00007fff90388c9c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
14  com.apple.CoreFoundation        0x00007fff90388c2f ___CFXRegistrationPost_block_invoke + 63
15  com.apple.CoreFoundation        0x00007fff90388ba7 _CFXRegistrationPost + 407
16  com.apple.CoreFoundation        0x00007fff90388912 ___CFXNotificationPost_block_invoke + 50
17  com.apple.CoreFoundation        0x00007fff903456d2 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1922
18  com.apple.CoreFoundation        0x00007fff90344925 _CFXNotificationPost + 693
19  com.apple.Foundation            0x00007fff8d07a0fa -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
20  com.apple.dt.DVTFoundation      0x000000010fc280c8 -[NSNotificationCenter(DVTNSNotificationCenterAdditions) _dvt_postNotificationName:object:userInfo:] + 698
21  com.apple.AppKit                0x00007fff958ad0fd -[NSView _postBoundsChangeNotification] + 175
22  com.apple.AppKit                0x00007fff958acfe2 -[NSView translateOriginToPoint:] + 287
23  com.apple.AppKit                0x00007fff958abbbc -[NSClipView _immediateScrollToPoint:] + 3760
24  com.apple.AppKit                0x00007fff958aac64 -[NSClipView scrollToPoint:] + 241
25  com.apple.AppKit                0x00007fff958e8678 -[NSScrollView scrollClipView:toPoint:] + 75
26  com.apple.AppKit                0x00007fff9588fd83 -[NSClipView _scrollTo:animateScroll:flashScrollerKnobs:] + 1692
27  com.apple.AppKit                0x00007fff9588f511 -[NSClipView _reflectDocumentViewFrameChange] + 128
28  com.apple.AppKit                0x00007fff957ec5b2 -[NSView _postFrameChangeNotification] + 196
29  com.apple.AppKit                0x00007fff957e7373 -[NSView setFrameSize:] + 2199
30  com.apple.AppKit                0x00007fff95888ea4 -[NSTextView(NSPrivate) _setFrameSize:forceScroll:] + 724
31  com.apple.AppKit                0x00007fff95888b7c -[NSTextView setFrameSize:] + 104
32  com.apple.dt.DVTKit             0x000000011012ecaa -[DVTSourceTextView setFrameSize:] + 45
33  com.apple.AppKit                0x00007fff958881af -[NSTextView setConstrainedFrameSize:] + 639
34  com.apple.UIFoundation          0x00007fff94cabeaa -[NSLayoutManager(NSPrivate) _resizeTextViewForTextContainer:] + 1073
35  com.apple.UIFoundation          0x00007fff94bc9192 -[NSLayoutManager textStorage:edited:range:changeInLength:invalidatedRange:] + 849
36  com.apple.dt.DVTKit             0x00000001102903d6 -[DVTFoldingLayoutManager textStorage:edited:range:changeInLength:invalidatedRange:] + 993
37  com.apple.UIFoundation          0x00007fff94bc9204 -[NSLayoutManager processEditingForTextStorage:edited:range:changeInLength:invalidatedRange:] + 47
38  com.apple.UIFoundation          0x00007fff94c11e80 -[NSTextStorage _notifyEdited:range:changeInLength:invalidatedRange:] + 152
39  com.apple.UIFoundation          0x00007fff94c1195e -[NSTextStorage processEditing] + 350
40  com.apple.dt.DVTKit             0x00000001101124db -[DVTTextStorage processEditing] + 82
41  com.apple.UIFoundation          0x00007fff94c11593 -[NSTextStorage endEditing] + 111
42  com.apple.dt.DVTKit             0x000000011011219d -[DVTTextStorage endEditing] + 652
43  com.apple.AppKit                0x00007fff9596acbc -[NSTextView insertText:replacementRange:] + 2657
44  com.apple.dt.DVTKit             0x0000000110163530 -[DVTCompletingTextView insertText:replacementRange:] + 146
45  com.kolinkrewinkel.Multiplex    0x000000011c8390a3 __57-[DVTSourceTextView(MPXEditorExtensions) deleteBackward:]_block_invoke + 2467 (DVTSourceTextView+MPXEditorExtensions.m:315)
46  com.kolinkrewinkel.MPXSelectionCore 0x000000011c85eb27 -[MPXSelectionManager mapSelectionsWithMovementDirection:modifyingSelections:usingBlock:] + 935 (MPXSelectionManager.m:243)
47  com.kolinkrewinkel.Multiplex    0x000000011c8386bd -[DVTSourceTextView(MPXEditorExtensions) deleteBackward:] + 189 (DVTSourceTextView+MPXEditorExtensions.m:325)
48  com.apple.AppKit                0x00007fff9598ad6f -[NSTextView doCommandBySelector:] + 195
49  com.apple.dt.DVTKit             0x000000011016fd5c -[DVTCompletingTextView doCommandBySelector:] + 268
50  com.apple.AppKit                0x00007fff9598ac86 -[NSTextInputContext(NSInputContext_WithCompletion) doCommandBySelector:completionHandler:] + 118
51  com.apple.AppKit                0x00007fff959669a1 -[NSKeyBindingManager(NSKeyBindingManager_MultiClients) interpretEventAsCommand:forClient:] + 1867
52  com.apple.AppKit                0x00007fff95970027 __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke978 + 335
53  com.apple.AppKit                0x00007fff9598ab46 __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke_3 + 95
54  com.apple.AppKit                0x00007fff9596fe99 -[NSTextInputContext tryHandleEvent_HasMarkedText_withDispatchCondition:dispatchWork:continuation:] + 101
55  com.apple.AppKit                0x00007fff9596fe23 __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke966 + 321
56  com.apple.HIToolbox             0x00007fff9653ff55 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_5 + 70
57  com.apple.HIToolbox             0x00007fff9653eedd ___ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec_block_invoke + 108
58  com.apple.AppKit                0x00007fff959691d4 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke176 + 2866
59  com.apple.AppKit                0x00007fff959685b4 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke_2 + 95
60  com.apple.AppKit                0x00007fff95968527 -[NSTextInputContext tryHandleTSMEvent_HasMarkedText_withDispatchCondition:dispatchWork:continuation:] + 101
61  com.apple.AppKit                0x00007fff95968217 -[NSTextInputContext handleTSMEvent:completionHandler:] + 3173
62  com.apple.AppKit                0x00007fff95967546 _NSTSMEventHandler + 324
63  com.apple.HIToolbox             0x00007fff964e798e DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 1231
64  com.apple.HIToolbox             0x00007fff964e6e18 SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 404
65  com.apple.HIToolbox             0x00007fff964e6c7b SendEventToEventTargetWithOptions + 43
66  com.apple.HIToolbox             0x00007fff9653c319 SendTSMEvent_WithCompletionHandler + 417
67  com.apple.HIToolbox             0x00007fff9653c808 __SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler_block_invoke + 400
68  com.apple.HIToolbox             0x00007fff9653c65b __SendFilterTextEvent_WithCompletionHandler_block_invoke + 189
69  com.apple.HIToolbox             0x00007fff9653c369 SendTSMEvent_WithCompletionHandler + 497
70  com.apple.HIToolbox             0x00007fff9653c14b SendFilterTextEvent_WithCompletionHandler + 236
71  com.apple.HIToolbox             0x00007fff9653be24 SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler + 284
72  com.apple.HIToolbox             0x00007fff9653bbd4 __utDeliverTSMEvent_WithCompletionHandler_block_invoke_2 + 296
73  com.apple.HIToolbox             0x00007fff9653ba78 __utDeliverTSMEvent_WithCompletionHandler_block_invoke + 437
74  com.apple.HIToolbox             0x00007fff9653b86c TSMKeyEvent_WithCompletionHandler + 721
75  com.apple.HIToolbox             0x00007fff9653b562 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_4 + 251
76  com.apple.HIToolbox             0x00007fff9653b3cc __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_3 + 325
77  com.apple.HIToolbox             0x00007fff9653b10a __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_2 + 261
78  com.apple.HIToolbox             0x00007fff9653aecf __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke + 253
79  com.apple.HIToolbox             0x00007fff9653a576 TSMProcessRawKeyEventWithOptionsAndCompletionHandler + 3077
80  com.apple.AppKit                0x00007fff959673f7 __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke955 + 131
81  com.apple.AppKit                0x00007fff959660d9 -[NSTextInputContext tryTSMProcessRawKeyEvent:dispatchCondition:setupForDispatch:furtherCondition:dispatchWork:continuation:] + 131
82  com.apple.AppKit                0x00007fff95965dd3 -[NSTextInputContext _handleEvent:options:completionHandler:] + 1266
83  com.apple.AppKit                0x00007fff959658a6 -[NSTextInputContext handleEvent:] + 109
84  com.apple.AppKit                0x00007fff959657af -[NSView interpretKeyEvents:] + 204
85  com.apple.AppKit                0x00007fff959655da -[NSTextView keyDown:] + 658
86  com.apple.AppKit                0x00007fff95f88b79 -[NSWindow _reallySendEvent:isDelayedEvent:] + 2108
87  com.apple.AppKit                0x00007fff959cdb8d -[NSWindow sendEvent:] + 517
88  com.apple.dt.IDEKit             0x00000001110ab31e -[IDEWorkspaceWindow sendEvent:] + 156
89  com.apple.AppKit                0x00007fff9594e259 -[NSApplication sendEvent:] + 4382
90  com.apple.dt.IDEKit             0x0000000110e61ae9 -[IDEApplication sendEvent:] + 739
91  com.apple.AppKit                0x00007fff957b4d9a -[NSApplication run] + 796
92  com.apple.AppKit                0x00007fff9577dfbe NSApplicationMain + 1176
93  libdyld.dylib                   0x00007fff9c4c15ad start + 1

A scroll gets triggered before the selections change but after the text is modified, leading to an out of bounds exception. We either need to just do a sanity check (the cheap fix) or somehow figure out how to defer the scroll or make the selection update happen beforehand. Alternatively, the -scrollViewDidScroll: side-effects could be wrapped in a dispatch_async(), another cheap fix.