getTextWidth() includes carriage returns?

I have a texteditor that resizes itself based on the size of its text using getTextWidth().

I've noticed that if I type a line, and then hit "return" to start a new line, this "return" counts as text at the end of that line and increases the "TextWidth" value, even though this "return" does not show up as visible text.

Is there anyway around this?

If you use a GlyphArrangement, you can get it to give the bounding box excluding whitespace.

(Or of course you could just do trim() before getting the string width!)