fix bug that the last character of the buffer is not highlighted