diff options
author | mathieui <mathieui@mathieui.net> | 2016-08-21 15:27:53 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2016-08-21 15:39:30 +0200 |
commit | 84e59b05ff0a17178da9ecdb6c5d084e48b42763 (patch) | |
tree | 224948d7c3d49a0005bff9390260357b3ec9c60e /poezio/tabs/basetabs.py | |
parent | 6c270b363ac018dfd4d66b23af95efcc35610da0 (diff) | |
download | poezio-84e59b05ff0a17178da9ecdb6c5d084e48b42763.tar.gz poezio-84e59b05ff0a17178da9ecdb6c5d084e48b42763.tar.bz2 poezio-84e59b05ff0a17178da9ecdb6c5d084e48b42763.tar.xz poezio-84e59b05ff0a17178da9ecdb6c5d084e48b42763.zip |
Don’t call input completion() functions inside completion methods
Use a placeholder object that can run it afterwards, so that we don’t
have side effects inside those functions.
Diffstat (limited to 'poezio/tabs/basetabs.py')
-rw-r--r-- | poezio/tabs/basetabs.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py index dbd57aa4..5e753643 100644 --- a/poezio/tabs/basetabs.py +++ b/poezio/tabs/basetabs.py @@ -20,7 +20,7 @@ import string import time from xml.etree import cElementTree as ET -from poezio.core.structs import Command +from poezio.core.structs import Command, Completion from poezio import timed_events from poezio import windows from poezio import xhtml @@ -230,7 +230,10 @@ class Tab(object): if command.comp is None: return False # There's no completion function else: - return command.comp(the_input) + comp = command.comp(the_input) + if comp: + return comp.run() + return comp return False def execute_command(self, provided_text): @@ -633,7 +636,7 @@ class ChatTab(Tab): def completion_correct(self, the_input): if self.last_sent_message and the_input.get_argument_position() == 1: - return the_input.auto_completion([self.last_sent_message['body']], '', quotify=False) + return Completion(the_input.auto_completion, [self.last_sent_message['body']], '', quotify=False) @property def inactive(self): |