[TextEditor] Removed some code duplication.