diff --git a/src/main/java/picocli/CommandLine.java b/src/main/java/picocli/CommandLine.java index 40bf3b344..93a691d11 100644 --- a/src/main/java/picocli/CommandLine.java +++ b/src/main/java/picocli/CommandLine.java @@ -8680,16 +8680,7 @@ public String[] description() { private String[] expandVariables(String[] desc) { if (desc.length == 0) { return desc; } StringBuilder candidates = new StringBuilder(); - - boolean flag = false; - for (String s: desc) { - if (s.contains(DESCRIPTION_VARIABLE_COMPLETION_CANDIDATES)) { - flag = true; - break; - } - } - - if (completionCandidates() != null && flag) { + if (completionCandidates() != null) { for (String c : completionCandidates()) { if (candidates.length() > 0) { candidates.append(", "); } candidates.append(c); diff --git a/src/test/java/picocli/Issue1351.java b/src/test/java/picocli/Issue1351.java deleted file mode 100644 index 8eed9605a..000000000 --- a/src/test/java/picocli/Issue1351.java +++ /dev/null @@ -1,60 +0,0 @@ -package picocli; - -import org.junit.Test; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.NoSuchElementException; - -import static org.junit.Assert.assertEquals; - -public class Issue1351 { - static int flag = 0; - - static class MyIterator implements Iterator { - private int cursor; - private final String[] a; - - MyIterator(String[] a) { - this.a = a; - } - - @Override - public boolean hasNext() { - // Do something in the iterator, maybe talking to a server as was mentioned in issue 1351. - flag = flag + 1; - return this.cursor < this.a.length; - } - - @Override - public String next() { - int i = this.cursor; - if (i >= this.a.length) { - throw new NoSuchElementException(); - } else { - this.cursor = i + 1; - return this.a[i]; - } - } - } - - static class MyIterable implements Iterable { - @Override - public Iterator iterator() { - return new MyIterator(new String[]{"A", "B", "C"}); - } - } - - @CommandLine.Command - class TestCommand { - @CommandLine.Option(names = "-o", completionCandidates = MyIterable.class, - description = "Candidates: A, B, C") - String option; - } - - @Test - public void testIssue1351() { - CommandLine.usage(new TestCommand(), System.out); - assertEquals(0, flag); - } -}