Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option append_in_comment for show_in_comment #708

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions 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_);
shewer marked this conversation as resolved.
Show resolved Hide resolved
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;
shewer marked this conversation as resolved.
Show resolved Hide resolved
if (show_in_comment_) {
text = original->text();
if (show_tips) {
tips = simplified;
comment_formatter_.Apply(&tips);
}
if (append_in_comment_) {
org_comment = original->comment();
shewer marked this conversation as resolved.
Show resolved Hide resolved
}
} else {
text = simplified;
if (show_tips) {
Expand All @@ -263,8 +268,8 @@ void Simplifier::PushBack(const an<Candidate>& original,
}
}
}
result->push_back(New<ShadowCandidate>(original, "simplified", text, tips,
inherit_comment_));
result->push_back(New<ShadowCandidate>(original, "simplified", text,
org_comment + tips, inherit_comment_));
}

bool Simplifier::Convert(const an<Candidate>& original,
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;
shewer marked this conversation as resolved.
Show resolved Hide resolved
bool inherit_comment_ = true;
Projection comment_formatter_;
bool random_ = false;
Expand Down