public int complete()

in gshell-support/gshell-console/src/main/java/org/apache/geronimo/gshell/console/completer/StringsCompleter.java [56:81]


    public int complete(String buffer, final int cursor, final List candidates) {
        // buffer could be null
        assert candidates != null;

        if (buffer == null) {
            buffer = "";
        }

        SortedSet<String> matches = strings.tailSet(buffer);

        for (String match : matches) {
            if (!match.startsWith(buffer)) {
                break;
            }

            // noinspection unchecked
            candidates.add(match);
        }

        if (candidates.size() == 1) {
            // noinspection unchecked
            candidates.set(0, candidates.get(0) + " ");
        }

        return candidates.isEmpty() ? -1 : 0;
    }