Make nick cycle works with spaces in nicks, fix a possible bug if gc_refer_to_nick_char is not ",". Fixes #3810.
This commit is contained in:
parent
e341548d25
commit
df13948d87
|
@ -1831,12 +1831,16 @@ class GroupchatControl(ChatControlBase):
|
||||||
begin = ''
|
begin = ''
|
||||||
|
|
||||||
gc_refer_to_nick_char = gajim.config.get('gc_refer_to_nick_char')
|
gc_refer_to_nick_char = gajim.config.get('gc_refer_to_nick_char')
|
||||||
if len(self.nick_hits) and \
|
with_refer_to_nick_char = False
|
||||||
self.nick_hits[0].startswith(begin.replace(
|
if begin.endswith(gc_refer_to_nick_char):
|
||||||
gc_refer_to_nick_char, '')) and \
|
with_refer_to_nick_char = True
|
||||||
self.last_key_tabs: # we should cycle
|
if len(self.nick_hits) and self.last_key_tabs and \
|
||||||
|
(text[:-1].endswith(self.nick_hits[0]) or \
|
||||||
|
text[:-2].endswith(self.nick_hits[0])): # we should cycle
|
||||||
|
# Previous nick in list may had a space inside, so we check text and
|
||||||
|
# not splitted_text and store it into 'begin' var
|
||||||
self.nick_hits.append(self.nick_hits[0])
|
self.nick_hits.append(self.nick_hits[0])
|
||||||
self.nick_hits.pop(0)
|
begin = self.nick_hits.pop(0)
|
||||||
else:
|
else:
|
||||||
self.nick_hits = [] # clear the hit list
|
self.nick_hits = [] # clear the hit list
|
||||||
list_nick = gajim.contacts.get_nick_list(self.account,
|
list_nick = gajim.contacts.get_nick_list(self.account,
|
||||||
|
@ -1854,12 +1858,14 @@ class GroupchatControl(ChatControlBase):
|
||||||
# the word is the begining of a nick
|
# the word is the begining of a nick
|
||||||
self.nick_hits.append(nick)
|
self.nick_hits.append(nick)
|
||||||
if len(self.nick_hits):
|
if len(self.nick_hits):
|
||||||
if len(splitted_text) < 2: # This is the 1st word of the line or no word
|
if len(splitted_text) < 2 or with_refer_to_nick_char:
|
||||||
|
# This is the 1st word of the line or no word or we are cycling
|
||||||
|
# at the beginning, possibly with a space in one nick
|
||||||
add = gc_refer_to_nick_char + ' '
|
add = gc_refer_to_nick_char + ' '
|
||||||
else:
|
else:
|
||||||
add = ' '
|
add = ' '
|
||||||
start_iter = end_iter.copy()
|
start_iter = end_iter.copy()
|
||||||
if self.last_key_tabs and begin.endswith(', '):
|
if self.last_key_tabs and with_refer_to_nick_char:
|
||||||
# have to accomodate for the added space from last
|
# have to accomodate for the added space from last
|
||||||
# completion
|
# completion
|
||||||
start_iter.backward_chars(len(begin) + 2)
|
start_iter.backward_chars(len(begin) + 2)
|
||||||
|
|
Loading…
Reference in New Issue