Fix bug #3165 (:history throws irrefutable pattern failed)