My document's NSTextView is enclosed in a NSScrollview subclass (to manage zooming). The zoom level change is managed by this NSScrollView subclass here:
- (void)setScaleFactor:(CGFloat)newScaleFactor {
if (newScaleFactor != self.scaleFactor){
[self setMagnification:newScaleFactor];
self.scaleFactor = newScaleFactor;
CGFloat scaler = newScaleFactor / self.scaleFactor;
[self.documentView scaleUnitSquareToSize:NSMakeSize(scaler, scaler)];
NSLayoutManager* lm = [self.documentView layoutManager];
NSTextContainer* tc = [self.documentView textContainer];
[lm ensureLayoutForTextContainer:tc];
}
}
On Mojave, everything behaves normally (zoom factor between 75% and 200%). When the document content cannot be displayed totally in width (window too small), I can scroll horizontally without any problem. On Catalina, when I scroll horizontally (and sometimes vertically) there are unwanted scrolls (for example back or forward to the cursor, sometimes to the left or to the right). After hours of tests/analysis I noticed only one different behaviour of the scrollview between the two MacOS versions. On Mojave, the maximum NSTextView width is not modified by the zoom, and scroll to the right is constrained. On Catalina, I can scroll indefinitely to the right (tested until a 125 inches width on the ruler).
What can explain such a difference of behaviour between the two MacOS versions on such basic objects (NSTextView, NSScrollView)? What did I missed?