2 small TextEditor bugs

Hey JUCE team,

There are 2 small bugs with the TextEditor that result in unexpected/glitchy behavior when clicking around them.

  1. Clicking slightly above (or below, if multiline is false) entered text sets the caret position to 0 instead of the x position.

Setting the caret position currently doesn’t take into account the borderSize nor the top indent, as they are removed from the call to indexAtPosition.

I can reproduce in DemoRunner and shipping juce apps. Easiest way to reproduce is set a big border size or indent.

  1. Setting the caret position in a multi line editor doesn’t take line spacing into account.

This turns line spacing into “no man’s land” with unintentional behavior: caret positions to the end of line instead of at mouse x. Easiest way to reproduce is set lineSpacing to something large like 2.

I opened a PR with fixes for both (each in their own commit).