From d77955fb1ae339236208825e639fa29a737bc422 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Thu, 31 Aug 2017 14:51:11 -0700 Subject: [PATCH] Pass the width constraint to the text layout engine if ellipsizing is enabled (#11877) --- packages/flutter/lib/src/rendering/paragraph.dart | 5 ++++- packages/flutter/test/rendering/paragraph_test.dart | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/flutter/lib/src/rendering/paragraph.dart b/packages/flutter/lib/src/rendering/paragraph.dart index c10c7bded1..14d9f614db 100644 --- a/packages/flutter/lib/src/rendering/paragraph.dart +++ b/packages/flutter/lib/src/rendering/paragraph.dart @@ -148,7 +148,10 @@ class RenderParagraph extends RenderBox { } void _layoutText({ double minWidth: 0.0, double maxWidth: double.INFINITY }) { - _textPainter.layout(minWidth: minWidth, maxWidth: _softWrap ? maxWidth : double.INFINITY); + _textPainter.layout( + minWidth: minWidth, + maxWidth: _softWrap || _overflow == TextOverflow.ellipsis ? maxWidth : double.INFINITY + ); } void _layoutTextWithConstraints(BoxConstraints constraints) { diff --git a/packages/flutter/test/rendering/paragraph_test.dart b/packages/flutter/test/rendering/paragraph_test.dart index 9394bd8b49..1b67e88a7a 100644 --- a/packages/flutter/test/rendering/paragraph_test.dart +++ b/packages/flutter/test/rendering/paragraph_test.dart @@ -132,7 +132,7 @@ void main() { expect(paragraph.size.height, equals(lineHeight)); relayoutWith(maxLines: 3, softWrap: false, overflow: TextOverflow.ellipsis); - expect(paragraph.size.height, equals(2 * lineHeight)); + expect(paragraph.size.height, equals(3 * lineHeight)); relayoutWith(maxLines: null, softWrap: false, overflow: TextOverflow.ellipsis); expect(paragraph.size.height, equals(2 * lineHeight));