Fixes StringIndexOutOfBoundsException when tab is pressed in the write
panel in the chat room window to search for contact and the pattern is
empty string. Patch provided by Danny van Heumen.