Modifying NSTextStorage attributes causes scroll view to jump around

I have finally found out from my observations that the jumping happens not only when pressing spacebar but for other keys such as backspace as well and this happens exactly when both of these happen.
- Non-contiguous layout is turned on
- Any modification, even to attributes, of text preceding the visible region is made inside -textStorageDidProcessEditing:
Looks like it is a bug in Non-contiguous layout feature! Would be good if an expert could confirm.
It appears to have nothing to do with calling -beginEditing and -endEditing.


Eric. I don't know if you solved this. However, I ran into a similar problem and I found out that turning off "Non-contiguous layout" option in the XCode 4.x attributes inspector for the NSTextView in case will solve the problem. The documentation for NSLayoutManager provides more clues (under "Overview" section): "Noncontiguous layout is an optional layout manager behavior new in Mac OS X v10.5...".

Here's the post

In my case, I experienced this behavior irrespective of using delegate methods or intermediate methods called via notifications and happened only when the text storage content became larger than the enclosing text view, causing scrolling to be active and "pushing" the text view to the top. After turning the option off, the "jump" was no longer observed. Hope it helps. Tom


Turns out calling -beginEditing and -endEditing inside a -textStorageDidProcessEditing: function is not very healthy! I switched to the NSTextViews -didChangeText instead.