diff --git a/src/groupchat_control.py b/src/groupchat_control.py
index 68659aef1ce9e35428a3965942d861074491f29f..7e9c35afad0b7342ad07bc8c759171cc951da3a0 100644
--- a/src/groupchat_control.py
+++ b/src/groupchat_control.py
@@ -1844,8 +1844,8 @@ class GroupchatControl(ChatControlBase):
 				else:
 					add = ' '
 				start_iter = end_iter.copy()
-				if self.last_key_tabs and with_refer_to_nick_char or \
-				text[-1] == ' ':
+				if self.last_key_tabs and with_refer_to_nick_char or (text and \
+				text[-1] == ' '):
 					# have to accomodate for the added space from last
 					# completion
 					# gc_refer_to_nick_char may be more than one char!