Skip to content

Commit

Permalink
fix(speller): make simple candidates auto-selectable
Browse files Browse the repository at this point in the history
  • Loading branch information
ksqsf authored and lotem committed Jun 17, 2024
1 parent 13228c2 commit 3ecadd2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/rime/gear/speller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,17 @@ static inline bool is_table_entry(const an<Candidate>& cand) {
return type == "table" || type == "user_table";
}

static inline bool is_simple_candidate(const an<Candidate>& cand) {
return bool(As<SimpleCandidate>(cand));
}

static bool is_auto_selectable(const an<Candidate>& cand,
const string& input,
const string& delimiters) {
return
// reaches end of input
cand->end() == input.length() && is_table_entry(cand) &&
cand->end() == input.length() &&
(is_table_entry(cand) || is_simple_candidate(cand)) &&
// no delimiters
input.find_first_of(delimiters, cand->start()) == string::npos;
}
Expand Down

0 comments on commit 3ecadd2

Please sign in to comment.