Fix off-by-one range error when replacing bracketed ranges