restore caret position when canonicalize