From c1c8035fe22f3e98e18dbaa95178e84d600a1218 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Fri, 20 Jan 2023 01:14:37 +0100 Subject: Fix bugs when changing input while completing --- slack/slack_conversation.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'slack/slack_conversation.py') diff --git a/slack/slack_conversation.py b/slack/slack_conversation.py index bd727c4..d078ead 100644 --- a/slack/slack_conversation.py +++ b/slack/slack_conversation.py @@ -2,7 +2,7 @@ from __future__ import annotations import time from contextlib import contextmanager -from typing import TYPE_CHECKING, List, Optional +from typing import TYPE_CHECKING, List, Literal, Optional, Union import weechat @@ -37,8 +37,12 @@ class SlackConversation: self.history_filled = False self.history_pending = False - self.is_completing = False - self.completion_context = 0 + self.completion_context: Union[ + Literal["NO_COMPLETION"], + Literal["PENDING_COMPLETION"], + Literal["ACTIVE_COMPLETION"], + Literal["IN_PROGRESS_COMPLETION"], + ] = "NO_COMPLETION" self.completion_values: List[str] = [] self.completion_index = 0 @@ -58,11 +62,11 @@ class SlackConversation: @contextmanager def completing(self): - self.is_completing = True + self.completion_context = "IN_PROGRESS_COMPLETION" try: yield finally: - self.is_completing = False + self.completion_context = "ACTIVE_COMPLETION" async def init(self): with self.loading(): -- cgit