diff --git a/src/rime/common.h b/src/rime/common.h index 0499b3a27e..fc34b8bb4f 100644 --- a/src/rime/common.h +++ b/src/rime/common.h @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include diff --git a/src/rime/context.cc b/src/rime/context.cc index 2de374ca92..1e325cd83e 100644 --- a/src/rime/context.cc +++ b/src/rime/context.cc @@ -143,27 +143,26 @@ bool Context::Highlight(size_t index) { return true; } -bool Context::DeleteCandidate(std::optional index) { - if (composition_.empty()) - return false; - Segment& seg(composition_.back()); - auto cand = index ? seg.GetCandidateAt(*index) : seg.GetSelectedCandidate(); +bool Context::DeleteCandidate(an cand) { if (!cand) return false; DLOG(INFO) << "Deleting candidate: " << cand->text(); - if (index) { - seg.selected_index = *index; - } delete_notifier_(this); return true; // CAVEAT: this doesn't mean anything is deleted for sure } bool Context::DeleteCandidate(size_t index) { - return DeleteCandidate(std::optional{index}); + if (composition_.empty()) + return false; + Segment& seg(composition_.back()); + return DeleteCandidate(seg.GetCandidateAt(index)); } bool Context::DeleteCurrentSelection() { - return DeleteCandidate({}); + if (composition_.empty()) + return false; + Segment& seg(composition_.back()); + return DeleteCandidate(seg.GetSelectedCandidate()); } bool Context::ConfirmCurrentSelection() { diff --git a/src/rime/context.h b/src/rime/context.h index cb6c3292f6..3c06a9dd98 100644 --- a/src/rime/context.h +++ b/src/rime/context.h @@ -94,7 +94,7 @@ class RIME_API Context { private: string GetSoftCursor() const; - bool DeleteCandidate(std::optional index); + bool DeleteCandidate(an cand); string input_; size_t caret_pos_ = 0;