teiiddes-1961: Chacged to use caret postion prior to setText() in case the user was editing the middle of the text vale.