replicated code related to **document changes** from cursor