Commit 59c10ea4 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

src: Make the cost of suffix matched option 0

parent 37d41313
...@@ -326,8 +326,10 @@ void show_candidates(const char *unkopt, option *options) ...@@ -326,8 +326,10 @@ void show_candidates(const char *unkopt, option *options)
} }
auto cands = std::vector<std::pair<int, const char*>>(); auto cands = std::vector<std::pair<int, const char*>>();
for(size_t i = 0; options[i].name != nullptr; ++i) { for(size_t i = 0; options[i].name != nullptr; ++i) {
// Use cost 0 for prefix match // Use cost 0 for prefix or suffix match
if(istartsWith(options[i].name, unkopt)) { if(istartsWith(options[i].name, unkopt) ||
iendsWith(options[i].name, options[i].name + strlen(options[i].name),
unkopt, unkopt + strlen(unkopt))) {
cands.emplace_back(0, options[i].name); cands.emplace_back(0, options[i].name);
continue; 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