Skip to content

Commit

Permalink
fix(editor): back_syllable should reopen selected words
Browse files Browse the repository at this point in the history
  • Loading branch information
lotem committed Jan 15, 2022
1 parent 33d85ad commit a3fdad8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/rime/gear/editor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,26 @@ void Editor::BackToPreviousInput(Context* ctx) {
ctx->PopInput();
}

void Editor::BackToPreviousSyllable(Context* ctx) {
static bool pop_input_by_syllable(Context* ctx) {
size_t caret_pos = ctx->caret_pos();
if (caret_pos == 0)
return;
return false;
if (auto cand = ctx->GetSelectedCandidate()) {
if (auto phrase = As<Phrase>(Candidate::GetGenuineCandidate(cand))) {
size_t stop = phrase->spans().PreviousStop(caret_pos);
if (stop != caret_pos) {
ctx->PopInput(caret_pos - stop);
return;
return true;
}
}
}
ctx->PopInput();
return false;
}

void Editor::BackToPreviousSyllable(Context* ctx) {
ctx->ReopenPreviousSelection() ||
((pop_input_by_syllable(ctx) || ctx->PopInput()) &&
ctx->ReopenPreviousSegment());
}

void Editor::DeleteCandidate(Context* ctx) {
Expand Down

0 comments on commit a3fdad8

Please sign in to comment.