Skip to content

Commit

Permalink
Only select default candidate if typing any character producing key d…
Browse files Browse the repository at this point in the history
…oesn't commit the current input.

e.g. n|ihao & type "," will select 你. User may still repeatly type ","
to do the default selection.
  • Loading branch information
wengxt committed Jan 19, 2025
1 parent 362aaaa commit d944fca
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions im/pinyin/pinyin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1767,6 +1767,18 @@ bool PinyinEngine::handlePunc(KeyEvent &event,
candidateList->candidate(0).select(inputContext);
}

// We can't emit punctuation right now, since it's not yet fully selected.
// There is an option to split the current input, however, it may not be
// sane to do so based on the partial input and cursor location. E.g.
// current input is n|i hao, and you press ",". Candidate will be filtered
// until "ni", instead of "n". which means you are not inserting "," between
// n & i. Thus, let's just make it select the default candidate.
// Also, it can not work with punctuation candidate, or type punc in pair.
if (!state->context_.empty()) {
event.filterAndAccept();
return true;
}

std::string punc;
std::string puncAfter;
// skip key pad
Expand Down

0 comments on commit d944fca

Please sign in to comment.