aboutsummaryrefslogtreecommitdiffstats
path: root/slack/register.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-01-20 01:14:37 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:53 +0100
commitc1c8035fe22f3e98e18dbaa95178e84d600a1218 (patch)
treede1b16656aee42bcb94ed17205440e11610c8e35 /slack/register.py
parent694917083a7eacab68f4257e6bf63c711863b9fc (diff)
downloadwee-slack-c1c8035fe22f3e98e18dbaa95178e84d600a1218.tar.gz
Fix bugs when changing input while completing
Diffstat (limited to 'slack/register.py')
-rw-r--r--slack/register.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/slack/register.py b/slack/register.py
index fd38956..2994e7f 100644
--- a/slack/register.py
+++ b/slack/register.py
@@ -31,13 +31,21 @@ def signal_buffer_switch_cb(data: str, signal: str, buffer_pointer: str) -> int:
def input_text_changed_cb(data: str, signal: str, buffer_pointer: str) -> int:
- conversation = get_conversation_from_buffer_pointer(buffer_pointer)
- if conversation:
- if not conversation.is_completing and conversation.completion_context:
- conversation.completion_context = 0
+ reset_completion_context_on_input(buffer_pointer)
+ return weechat.WEECHAT_RC_OK
+
+
+def input_text_cursor_moved_cb(data: str, signal: str, buffer_pointer: str) -> int:
+ reset_completion_context_on_input(buffer_pointer)
return weechat.WEECHAT_RC_OK
+def reset_completion_context_on_input(buffer_pointer: str):
+ conversation = get_conversation_from_buffer_pointer(buffer_pointer)
+ if conversation and conversation.completion_context != "IN_PROGRESS_COMPLETION":
+ conversation.completion_context = "NO_COMPLETION"
+
+
def modifier_input_text_display_with_cursor_cb(
data: str, modifier: str, buffer_pointer: str, string: str
) -> str:
@@ -111,6 +119,9 @@ def register():
weechat.hook_signal(
"input_text_changed", get_callback_name(input_text_changed_cb), ""
)
+ weechat.hook_signal(
+ "input_text_cursor_moved", get_callback_name(input_text_cursor_moved_cb), ""
+ )
weechat.hook_modifier(
"input_text_display_with_cursor",
get_callback_name(modifier_input_text_display_with_cursor_cb),