Skip to content

Commit a3fdad8

Browse files
committed
fix(editor): back_syllable should reopen selected words
1 parent 33d85ad commit a3fdad8

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/rime/gear/editor.cc

+10-4
Original file line numberDiff line numberDiff line change
@@ -133,20 +133,26 @@ void Editor::BackToPreviousInput(Context* ctx) {
133133
ctx->PopInput();
134134
}
135135

136-
void Editor::BackToPreviousSyllable(Context* ctx) {
136+
static bool pop_input_by_syllable(Context* ctx) {
137137
size_t caret_pos = ctx->caret_pos();
138138
if (caret_pos == 0)
139-
return;
139+
return false;
140140
if (auto cand = ctx->GetSelectedCandidate()) {
141141
if (auto phrase = As<Phrase>(Candidate::GetGenuineCandidate(cand))) {
142142
size_t stop = phrase->spans().PreviousStop(caret_pos);
143143
if (stop != caret_pos) {
144144
ctx->PopInput(caret_pos - stop);
145-
return;
145+
return true;
146146
}
147147
}
148148
}
149-
ctx->PopInput();
149+
return false;
150+
}
151+
152+
void Editor::BackToPreviousSyllable(Context* ctx) {
153+
ctx->ReopenPreviousSelection() ||
154+
((pop_input_by_syllable(ctx) || ctx->PopInput()) &&
155+
ctx->ReopenPreviousSegment());
150156
}
151157

152158
void Editor::DeleteCandidate(Context* ctx) {

0 commit comments

Comments
 (0)