]> git.neil.brown.name Git - edlib.git/commitdiff
Merge branch 'master' of home.neil.brown.name:GIT/edlib
authorNeilBrown <neil@brown.name>
Fri, 21 Feb 2020 21:19:30 +0000 (08:19 +1100)
committerNeilBrown <neil@brown.name>
Fri, 21 Feb 2020 21:19:30 +0000 (08:19 +1100)
1  2 
render-complete.c

index e301564ff3a81505a539c9462a000c16c7abced2,9307e3975e58d8486bb3faab6e3936b091c912a1..c05ac0784a333eedbf3d2496e741043749693954
@@@ -391,16 -393,11 +394,16 @@@ DEF_CMD(complete_set_prefix
        struct complete_data *cd = p->data;
        struct mark *m;
        struct mark *m2 = NULL;
-       char *c;
+       const char *c;
        int cnt = 0;
        char *common = NULL;
 +      /* common_pre is the longest common prefix to 'common' that
 +       * appears in all matches in which 'common' appears.  It is
 +       * allocated with enough space to append 'common' after the
 +       * prefix.
 +       */
        char *common_pre = NULL;
 -      int at_start = 0;
 +      int best_match = 0;
  
        if (!ci->str)
                return Enoarg;
  
        while (do_render_complete_prev(cd, m, p->parent, 1, &c) > 0 && c) {
                int l;
-               char *match;
 -              const char *match = c;
 -              if (!cd->prefix_only)
 -                      match = strstr(match, cd->prefix);
++              const char *match;
 +              int this_match = 0;
 +
 +              if (cd->prefix_only) {
 +                      match = c;
 +                      if (strncmp(c, cd->prefix, strlen(cd->prefix)) == 0)
 +                              this_match += 1;
 +              } else {
 +                      match = strcasestr(c, cd->prefix);
 +                      if (strncasecmp(c, cd->prefix, strlen(cd->prefix)) == 0) {
 +                              this_match += 1;
 +                              if (strncmp(c, cd->prefix, strlen(cd->prefix)) == 0)
 +                                      this_match += 1;
 +                      } else if (strstr(c, cd->prefix))
 +                              this_match += 1;
 +              }
                if (!match)
 +                      /* should be impossible */
                        break;
                l = strlen(match);
                if (l && match[l-1] == '\n')