Merge pull request #10352 from davidflanagan/bug882197

Bug 882197: remember cursor position after calling replaceSurroundingText r=dhylands(cherry picked from commit d86821224617d03f566fa7668e5fe68df764893e)