fix preserving caret selection while removing trailing white spaces.