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 e13feae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 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_
8 changes: 3 additions & 5 deletions test/table_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <rime/algo/syllabifier.h>
#include <rime/dict/table.h>


class RimeTableTest : public ::testing::Test {
public:
virtual void SetUp() {
Expand All @@ -23,9 +22,8 @@ class RimeTableTest : public ::testing::Test {
}
table_->Load();
}
virtual void TearDown() {
table_->Close();
}
virtual void TearDown() { table_->Close(); }

protected:
static const int total_num_entries = 8;
static const char file_name[];
Expand Down Expand Up @@ -92,7 +90,7 @@ void RimeTableTest::PrepareSampleVocabulary(rime::Syllabary& syll,
d->code.resize(3);
d->code.push_back(2);
d->code.push_back(1);
d->text = "yi-er-san-er-yi";
d->text = "yi-er-san-er-yi";
(*lv4)[-1].entries.push_back(d);
}

Expand Down

0 comments on commit e13feae

Please sign in to comment.