diff --git a/src/hallelujah.cpp b/src/hallelujah.cpp index 45c9ec7..4d207b3 100644 --- a/src/hallelujah.cpp +++ b/src/hallelujah.cpp @@ -177,17 +177,13 @@ void HallelujahState::keyEvent(KeyEvent &event) { words.begin(), words.begin() + n, words.end(), [this, &normalized](const std::string &a, const std::string &b) { - if (a == normalized) { - return true; - } - if (b == normalized) { - return false; - } + auto na = a == normalized ? 1 : 0; + auto nb = b == normalized ? 1 : 0; auto ia = words_->find(a); auto fa = ia == words_->end() ? 0 : ia->second.frequency_; auto ib = words_->find(b); auto fb = ib == words_->end() ? 0 : ib->second.frequency_; - return fa > fb; + return std::tie(na, fa, a) > std::tie(nb, fb, b); }); words.resize(n); } else { diff --git a/test/testhallelujah.cpp b/test/testhallelujah.cpp index 30c2fd8..3ad9174 100644 --- a/test/testhallelujah.cpp +++ b/test/testhallelujah.cpp @@ -12,7 +12,7 @@ using namespace fcitx; std::vector, std::vector>> expectedCommit{ - {{"a", "4"}, {"at"}}, + {{"a", "4"}, {"are"}}, {{"a", "space"}, {"a "}}, {{"a", "Return"}, {"a"}}, {{"a", "Down", "space"}, {"as "}},