@Override
public boolean complete(final ConsoleReader reader, final List<CharSequence> candidates, final int pos) throws
IOException
{
CursorBuffer buf = reader.getCursorBuffer();
PluginCommandCompleterState state = commandHolder.getState();
if (state != null)
{
if (((candidates.size() == 1) && "".equals(candidates.get(0)))
|| (state.isDuplicateBuffer() && state.isFinalTokenComplete()))
{
if (commandHolder.getState().getOption() != null)
{
OptionMetadata option = commandHolder.getState().getOption();
reader.println();
reader.println(option.getOptionDescriptor());
if (candidates.size() == 1)
{
reader.println();
reader.drawLine();
return true;
}
}
}
}
// if there is only one completion, then fill in the buffer
if (candidates.size() == 1)
{
CharSequence value = candidates.get(0);
// fail if the only candidate is the same as the current buffer
if (value.equals(buf.toString()))
{
return false;
}
setBuffer(reader, value, pos);