How to mark decoration.replace as error

I have reverted this patch again, since it caused issues. It doesn’t seem entirely unreasonable, when you replace the marked text, for the mark to become invisible.