Fix a warning about a position out of range.

May happen when selecting a text in diff editor.

Change-Id: I2c4790c42c91623fc8b4cabef8a4604de9fd4cef
Reviewed-by: hjk <hjk121@nokiamail.com>
Reviewed-by: David Schulz <david.schulz@digia.com>