diff --git a/src/libime/table/tablebaseddictionary.cpp b/src/libime/table/tablebaseddictionary.cpp index 6986cda..5b6349a 100644 --- a/src/libime/table/tablebaseddictionary.cpp +++ b/src/libime/table/tablebaseddictionary.cpp @@ -1324,17 +1324,18 @@ bool TableBasedDictionary::hasMatchingWords(std::string_view code) const { } bool TableBasedDictionary::hasOneMatchingWord(std::string_view code) const { - bool hasMatch = false; + bool hasOneMatch = false; matchWords( code, TableMatchMode::Prefix, - [&hasMatch](std::string_view, std::string_view, uint32_t, PhraseFlag) { - if (hasMatch) { + [&hasOneMatch](std::string_view, std::string_view, uint32_t, PhraseFlag) { + if (hasOneMatch) { + hasOneMatch = false; return false; } - hasMatch = true; + hasOneMatch = true; return true; }); - return hasMatch; + return hasOneMatch; } PhraseFlag TableBasedDictionary::wordExists(std::string_view code, diff --git a/src/libime/table/tablecontext.cpp b/src/libime/table/tablecontext.cpp index b1b49b7..9dfd25c 100644 --- a/src/libime/table/tablecontext.cpp +++ b/src/libime/table/tablecontext.cpp @@ -173,7 +173,17 @@ class TableContextPrivate : public fcitx::QPtrHolder { if (!canDoAutoSelect()) { return false; } - return candidates_.size() == 1; + if (candidates_.size() != 1) { + return false; + } + + if (candidates_[0].sentence().size() != 1) { + return false; + } + FCITX_Q(); + return q->code(candidates_[0]) == q->currentCode() && + (!dict_.tableOptions().exactMatch() || + dict_.hasOneMatchingWord(q->currentCode())); }; State currentState() {