aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2019-06-05 01:38:50 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2019-06-06 00:36:49 +0200
commit3b6738ba91a000c38fe765962c2cbee8cb590e59 (patch)
tree583926214d6f592e911ee765f7daf9bc59c79f9a
parentf4497e99e7a4956840d8c6199f37d5b393a2f9b2 (diff)
downloadwee-slack-3b6738ba91a000c38fe765962c2cbee8cb590e59.tar.gz
Get the word that is being completed the proper way
Simplify emoji_completion_cb by using hook_completion_get_string to get the string that is being completed, instead of reading it out from the contents of the input.
-rw-r--r--wee_slack.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/wee_slack.py b/wee_slack.py
index dbe6446..4ac73c4 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -1002,10 +1002,10 @@ def emoji_completion_cb(data, completion_item, current_buffer, completion):
if current_channel is None:
return w.WEECHAT_RC_OK
- line_input = w.buffer_get_string(current_buffer, "input")
- current_pos = w.buffer_get_integer(current_buffer, "input_pos")
- current_word_match = re.search(r'[^: ]*:', line_input[:current_pos].split()[-1])
- prefix = current_word_match.group(0) if current_word_match else ':'
+ base_word = w.hook_completion_get_string(completion, "base_word")
+ if ":" not in base_word:
+ return w.WEECHAT_RC_OK
+ prefix = base_word.split(":")[0] + ":"
for emoji in current_channel.team.emoji_completions:
w.hook_completion_list_add(completion, prefix + emoji + ":", 0, w.WEECHAT_LIST_POS_SORT)