Skip to content

Commit

Permalink
add option append_in_comment for show_in_comment
Browse files Browse the repository at this point in the history
Signed-off-by: shewer <[email protected]>
  • Loading branch information
shewer committed Sep 6, 2023
1 parent be3af89 commit f6d8d25
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/rime/gear/simplifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ Simplifier::Simplifier(const Ticket& ticket)
: kTipsNone;
}
config->GetBool(name_space_ + "/show_in_comment", &show_in_comment_);
config->GetBool(name_space_ + "/append_in_comment", &append_in_comment_);
config->GetBool(name_space_ + "/inherit_comment", &inherit_comment_);
comment_formatter_.Load(config->GetList(name_space_ + "/comment_format"));
config->GetBool(name_space_ + "/random", &random_);
Expand Down Expand Up @@ -247,12 +248,16 @@ void Simplifier::PushBack(const an<Candidate>& original,
original->text().c_str() + original->text().length());
bool show_tips =
(tips_level_ == kTipsChar && length == 1) || tips_level_ == kTipsAll;
string org_comment;
if (show_in_comment_) {
text = original->text();
if (show_tips) {
tips = simplified;
comment_formatter_.Apply(&tips);
}
if (append_in_comment_) {
org_comment = original->comment();
}
} else {
text = simplified;
if (show_tips) {
Expand All @@ -263,7 +268,7 @@ void Simplifier::PushBack(const an<Candidate>& original,
}
}
}
result->push_back(New<ShadowCandidate>(original, "simplified", text, tips,
result->push_back(New<ShadowCandidate>(original, "simplified", text, org_comment +" " + tips,
inherit_comment_));
}

Expand Down
1 change: 1 addition & 0 deletions src/rime/gear/simplifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Simplifier : public Filter, TagMatching {
string opencc_config_;
set<string> excluded_types_;
bool show_in_comment_ = false;
bool append_in_comment_ = false;
bool inherit_comment_ = true;
Projection comment_formatter_;
bool random_ = false;
Expand Down

0 comments on commit f6d8d25

Please sign in to comment.