From f99c049652cdade40b6a44a14171062bfc253b13 Mon Sep 17 00:00:00 2001 From: Zijia Date: Fri, 20 Mar 2026 01:34:09 +0000 Subject: [PATCH] fix: reset DictypeState after stream completes --- DictypeFcitx/src/DictypeState.cpp | 3 +++ DictypeFcitx/src/DictypeState.test.cpp | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/DictypeFcitx/src/DictypeState.cpp b/DictypeFcitx/src/DictypeState.cpp index d5565fd..764c4c3 100644 --- a/DictypeFcitx/src/DictypeState.cpp +++ b/DictypeFcitx/src/DictypeState.cpp @@ -16,6 +16,9 @@ void DictypeState::clear() { DICTYPE_WARN() << "uncommitted texts: " << getUncommittedText(); texts_.clear(); } + errorMsg_.clear(); + stage_ = DictypeStage::Closed; + inputContext_.unwatch(); cleared_ = true; } diff --git a/DictypeFcitx/src/DictypeState.test.cpp b/DictypeFcitx/src/DictypeState.test.cpp index bb5fd7a..07cd274 100644 --- a/DictypeFcitx/src/DictypeState.test.cpp +++ b/DictypeFcitx/src/DictypeState.test.cpp @@ -108,8 +108,8 @@ TEST(DictypeStateTest, RetainErrorMessageUntilNewSession) { EXPECT_EQ(state.getErrorMsg(), "boom"); state.clear(); - EXPECT_EQ(state.getStage(), DictypeStage::Errored); - EXPECT_EQ(state.getErrorMsg(), "boom"); + EXPECT_EQ(state.getStage(), DictypeStage::Closed); + EXPECT_EQ(state.getErrorMsg(), ""); state.newSession(nullptr); EXPECT_EQ(state.getStage(), DictypeStage::Closed);