don't add the ',' after a last-word completion.

parent 374ab23b
......@@ -292,8 +292,10 @@ class Gui(object):
"""
room.users.remove(user)
by = presence.find('{http://jabber.org/protocol/muc#user}x/{http://jabber.org/protocol/muc#user}item/{http://jabber.org/protocol/muc#user}actor')
from common import debug
debug('KICK: by:%s %s, %s\n' % (presence, by, by.attrib['jid'] if by else by))
reason = presence.find('{http://jabber.org/protocol/muc#user}x/{http://jabber.org/protocol/muc#user}item/{http://jabber.org/protocol/muc#user}reason')
by = by.attrib['jid'] if by else ''
by = by.attrib['jid'] if by is not None else None
reason = reason.text# if reason else ''
if from_nick == room.own_nick: # we are kicked
room.disconnect()
......@@ -306,7 +308,7 @@ class Gui(object):
muc.join_groupchat(self.xmpp, room.name, room.own_nick)
else:
if by:
kick_msg = _('%(spec)s "[%(nick)s]" has been kicked by ["%(by)s]"') % {'spec':theme.CHAR_KICK.replace('"', '\\"'), 'nick':from_nick.replace('"', '\\"'), 'by':by.replace('"', '\\"')}
kick_msg = _('%(spec)s "[%(nick)s]" has been kicked by "[%(by)s]"') % {'spec':theme.CHAR_KICK.replace('"', '\\"'), 'nick':from_nick.replace('"', '\\"'), 'by':by.replace('"', '\\"')}
else:
kick_msg = _('%(spec)s "[%(nick)s]" has been kicked') % {'spec':theme.CHAR_KICK, 'nick':from_nick.replace('"', '\\"')}
if reason:
......@@ -531,7 +533,7 @@ class Gui(object):
word = word.replace(char, '')
if len(word) > 5:
words.append(word)
self.window.input.auto_completion(words)
self.window.input.auto_completion(words, False)
def go_to_important_room(self):
"""
......
......@@ -586,7 +586,7 @@ class Input(Win):
if reset:
self.rewrite_text()
def auto_completion(self, user_list):
def auto_completion(self, user_list, add_after=True):
"""
Complete the nickname
"""
......@@ -594,9 +594,9 @@ class Input(Win):
return # we don't complete if cursor is not at the end of line
completion_type = config.get('completion', 'normal')
if completion_type == 'shell' and self.text != '':
self.shell_completion(user_list)
self.shell_completion(user_list, add_after)
else:
self.normal_completion(user_list)
self.normal_completion(user_list, add_after)
def reset_completion(self):
"""
......@@ -605,12 +605,12 @@ class Input(Win):
self.hit_list = []
self.last_completion = None
def normal_completion(self, user_list):
def normal_completion(self, user_list, add_after):
"""
Normal completion
"""
if " " not in self.text.strip() or\
self.last_completion and self.text == self.last_completion+config.get('after_completion', ',')+" ":
if add_after and (" " not in self.text.strip() or\
self.last_completion and self.text == self.last_completion+config.get('after_completion', ',')+" "):
after = config.get('after_completion', ',')+" "
#if " " in self.text.strip() and (not self.last_completion or ' ' in self.last_completion):
else:
......@@ -640,11 +640,11 @@ class Input(Win):
self.text += nick +after
self.key_end(False)
def shell_completion(self, user_list):
def shell_completion(self, user_list, add_after):
"""
Shell-like completion
"""
if " " in self.text.strip():
if " " in self.text.strip() or not add_after:
after = " " # don't put the "," if it's not the begining of the sentence
else:
after = config.get('after_completion', ',')+" "
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment