Fix rewrite applyToRange and undoToRange.