diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index 4dbd362495..9c10ee2947 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp @@ -67,10 +67,10 @@ struct TextAtom class TextEditor::UniformTextSection { public: - UniformTextSection (const String& text, const Font& f, Colour col, juce_wchar passwordChar) - : font (f), colour (col) + UniformTextSection (const String& text, const Font& f, Colour col, juce_wchar passwordCharToUse) + : font (f), colour (col), passwordChar (passwordCharToUse) { - initialiseAtoms (text, passwordChar); + initialiseAtoms (text); } UniformTextSection (const UniformTextSection&) = default; @@ -78,7 +78,7 @@ public: UniformTextSection& operator= (const UniformTextSection&) = delete; - void append (UniformTextSection& other, const juce_wchar passwordChar) + void append (UniformTextSection& other) { if (! other.atoms.isEmpty()) { @@ -112,9 +112,9 @@ public: } } - UniformTextSection* split (int indexToBreakAt, juce_wchar passwordChar) + UniformTextSection* split (int indexToBreakAt) { - auto* section2 = new UniformTextSection (String(), font, colour, passwordChar); + auto* section2 = new UniformTextSection ({}, font, colour, passwordChar); int index = 0; for (int i = 0; i < atoms.size(); ++i) @@ -196,11 +196,12 @@ public: return total; } - void setFont (const Font& newFont, const juce_wchar passwordChar) + void setFont (const Font& newFont, const juce_wchar passwordCharToUse) { - if (font != newFont) + if (font != newFont || passwordChar != passwordCharToUse) { font = newFont; + passwordChar = passwordCharToUse; for (auto& atom : atoms) atom.width = newFont.getStringWidthFloat (atom.getText (passwordChar)); @@ -211,9 +212,10 @@ public: Font font; Colour colour; Array atoms; + juce_wchar passwordChar; private: - void initialiseAtoms (const String& textToParse, const juce_wchar passwordChar) + void initialiseAtoms (const String& textToParse) { auto text = textToParse.getCharPointer(); @@ -2511,7 +2513,7 @@ void TextEditor::splitSection (const int sectionIndex, const int charToSplitAt) jassert (sections[sectionIndex] != nullptr); sections.insert (sectionIndex + 1, - sections.getUnchecked (sectionIndex)->split (charToSplitAt, passwordCharacter)); + sections.getUnchecked (sectionIndex)->split (charToSplitAt)); } void TextEditor::coalesceSimilarSections() @@ -2524,7 +2526,7 @@ void TextEditor::coalesceSimilarSections() if (s1->font == s2->font && s1->colour == s2->colour) { - s1->append (*s2, passwordCharacter); + s1->append (*s2); sections.remove (i + 1); --i; }