@@ -298,17 +298,16 @@ static inline ENRMTextLayoutResult ENRMMeasureTextLayout(ENRMPlatformTextView *t
298298#define ENRMSetNeedsDisplay (view ) [(view) setNeedsDisplay: YES ]
299299#endif
300300
301- // / Refreshes a text view's layout and display after it is attached to a window.
302- // / On iOS, resets contentOffset to zero (NSTextView has no scroll position) .
303- // / Sets the frame and text container to the given bounds, invalidates layout for
304- // / any existing content, then triggers a redraw .
305- static inline void ENRMRefreshTextViewAfterWindowAttach (ENRMPlatformTextView *textView, CGRect bounds )
301+ // / Invalidates the text container, re-lays out any existing content, and
302+ // / triggers a redraw. On iOS also resets contentOffset to zero.
303+ // / Does NOT touch the text view's frame — callers that need to reposition
304+ // / the view should set the frame themselves before calling this .
305+ static inline void ENRMRefreshTextViewLayout (ENRMPlatformTextView *textView)
306306{
307307#if !TARGET_OS_OSX
308308 textView.contentOffset = CGPointZero;
309309#endif
310- textView.frame = bounds;
311- textView.textContainer .size = CGSizeMake (bounds.size .width , CGFLOAT_MAX);
310+ textView.textContainer .size = CGSizeMake (textView.bounds .size .width , CGFLOAT_MAX);
312311 NSUInteger textLength = ENRMGetAttributedText (textView).length ;
313312 if (textLength > 0 ) {
314313 [textView.layoutManager invalidateLayoutForCharacterRange: NSMakeRange (0 , textLength) actualCharacterRange: NULL ];
@@ -317,6 +316,15 @@ static inline void ENRMRefreshTextViewAfterWindowAttach(ENRMPlatformTextView *te
317316 ENRMSetNeedsDisplay (textView);
318317}
319318
319+ // / Refreshes a text view's layout and display after it is attached to a window.
320+ // / Sets the frame and text container to the given bounds, invalidates layout for
321+ // / any existing content, then triggers a redraw.
322+ static inline void ENRMRefreshTextViewAfterWindowAttach (ENRMPlatformTextView *textView, CGRect bounds)
323+ {
324+ textView.frame = bounds;
325+ ENRMRefreshTextViewLayout (textView);
326+ }
327+
320328// / Cross-platform text deselection: UITextView uses selectedTextRange (nullable);
321329// / NSTextView uses selectedRange (length-based).
322330static inline void ENRMClearSelection (ENRMPlatformTextView *textView)
0 commit comments