From 59c10ea4c291e2c1f0f04f5178c36905a1f3c71a Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 12 Jan 2014 22:02:19 +0900 Subject: [PATCH] src: Make the cost of suffix matched option 0 --- src/util.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/util.cc b/src/util.cc index d85becaa..3c82903a 100644 --- a/src/util.cc +++ b/src/util.cc @@ -326,8 +326,10 @@ void show_candidates(const char *unkopt, option *options) } auto cands = std::vector>(); for(size_t i = 0; options[i].name != nullptr; ++i) { - // Use cost 0 for prefix match - if(istartsWith(options[i].name, unkopt)) { + // 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))) { cands.emplace_back(0, options[i].name); continue; }