From a533e86044e9db3cbc097b1b5af93a26f83c4e8e Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 7 Apr 2021 12:31:46 +0100 Subject: [PATCH] TextEditor: Fixed a bug updating the text holder size for single-line editors --- modules/juce_gui_basics/widgets/juce_TextEditor.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index 233c23305d..2564055e38 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp @@ -681,6 +681,16 @@ struct TextEditor::Iterator return roundToInt (height); } + int getTextRight() + { + float maxWidth = 0.0f; + + while (next()) + maxWidth = jmax (maxWidth, atomRight); + + return roundToInt (maxWidth); + } + //============================================================================== int indexInText = 0; float lineY = 0, lineHeight = 0, maxDescent = 0; @@ -1437,7 +1447,8 @@ void TextEditor::checkLayout() if (getWordWrapWidth() > 0) { auto textBottom = Iterator (*this).getTotalTextHeight() + topIndent; - auto textRight = getMaximumTextWidth() + leftIndent + rightEdgeSpace; + auto textRight = jmax (getMaximumTextWidth() + leftIndent + rightEdgeSpace, + Iterator (*this).getTextRight()); textHolder->setSize (textRight, textBottom); viewport->setScrollBarsShown (scrollbarVisible