Skip to content

Commit

Permalink
Update context.cc
Browse files Browse the repository at this point in the history
  • Loading branch information
groverlynn committed Jul 17, 2023
1 parent a0578f9 commit f727c65
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 12 additions & 10 deletions src/rime/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,17 @@ void Context::Clear() {
}

bool Context::Select(size_t index) {
bool result = Peek(index);
if (result)
composition_.back().status = Segment::kSelected;
select_notifier_(this);
return result;
}
DLOG(INFO) << "Selection changed from: " << previous_index
<< " to: " << new_index;
return true;
if (composition_.empty())
return false;
Segment& seg(composition_.back());
if (auto cand = seg.GetCandidateAt(index)) {
seg.selected_index = index;
seg.status = Segment::kSelected;
DLOG(INFO) << "Selected: '" << cand->text() << "', index = " << index;
select_notifier_(this);
return true;
}
return false;
}

bool Context::DeleteCandidate(
Expand Down Expand Up @@ -290,4 +292,4 @@ void Context::ClearTransientOptions() {
}
}

} // namespace rime
} // namespace rime
2 changes: 1 addition & 1 deletion src/rime/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@ class Context {

} // namespace rime

#endif // RIME_CONTEXT_H_
#endif // RIME_CONTEXT_H_

0 comments on commit f727c65

Please sign in to comment.