Improving delete detection when the cursor is before the first character in a text