Commit a54c5bef authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

src: Must suffix-match at least 3 characters to be a option candidate

parent 8c6f3d10
......@@ -324,12 +324,14 @@ void show_candidates(const char *unkopt, option *options)
if(*unkopt == '\0') {
return;
}
auto unkoptlen = strlen(unkopt);
auto cands = std::vector<std::pair<int, const char*>>();
for(size_t i = 0; options[i].name != nullptr; ++i) {
// Use cost 0 for prefix or suffix match
if(istartsWith(options[i].name, unkopt) ||
iendsWith(options[i].name, options[i].name + strlen(options[i].name),
unkopt, unkopt + strlen(unkopt))) {
(unkoptlen >= 3 &&
iendsWith(options[i].name, options[i].name + strlen(options[i].name),
unkopt, unkopt + unkoptlen))) {
cands.emplace_back(0, options[i].name);
continue;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment