src: Must suffix-match at least 3 characters to be a option candidate
This commit is contained in:
parent
8c6f3d1054
commit
a54c5bef54
|
@ -324,12 +324,14 @@ void show_candidates(const char *unkopt, option *options)
|
||||||
if(*unkopt == '\0') {
|
if(*unkopt == '\0') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
auto unkoptlen = strlen(unkopt);
|
||||||
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 or suffix 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),
|
(unkoptlen >= 3 &&
|
||||||
unkopt, unkopt + strlen(unkopt))) {
|
iendsWith(options[i].name, options[i].name + strlen(options[i].name),
|
||||||
|
unkopt, unkopt + unkoptlen))) {
|
||||||
cands.emplace_back(0, options[i].name);
|
cands.emplace_back(0, options[i].name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue