[TextEditor] Improved calculation of fold rectangles