Skip to content

Commit

Permalink
#424: re-adding last relevant change (#561)
Browse files Browse the repository at this point in the history
  • Loading branch information
hohwille authored Aug 26, 2024
1 parent 44d5f02 commit 19b4d60
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -930,21 +930,30 @@ public List<CompletionCandidate> complete(CliArguments arguments, boolean includ
Commandlet firstCandidate = this.commandletManager.getCommandletByFirstKeyword(keyword);
boolean matches = false;
if (firstCandidate != null) {
matches = apply(arguments.copy(), firstCandidate, collector);
matches = completeCommandlet(arguments, firstCandidate, collector);
} else if (current.isCombinedShortOption()) {
collector.add(keyword, null, null, null);
}
if (!matches) {
for (Commandlet cmd : this.commandletManager.getCommandlets()) {
if (cmd != firstCandidate) {
apply(arguments.copy(), cmd, collector);
completeCommandlet(arguments, cmd, collector);
}
}
}
}
return collector.getSortedCandidates();
}

private boolean completeCommandlet(CliArguments arguments, Commandlet cmd, CompletionCandidateCollector collector) {
if (cmd.isIdeHomeRequired() && (this.ideHome == null)) {
return false;
} else {
return apply(arguments.copy(), cmd, collector);
}
}


/**
* @param arguments the {@link CliArguments} to apply. Will be {@link CliArguments#next() consumed} as they are matched. Consider passing a
* {@link CliArguments#copy() copy} as needed.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.devonfw.tools.ide.completion;

import java.nio.file.Path;

import org.junit.jupiter.api.Test;

import com.devonfw.tools.ide.cli.AutocompletionReaderTestSupport;
Expand Down Expand Up @@ -128,6 +126,6 @@ private IdeCompleter newCompleter() {

private IdeTestContext newTestContext() {

return new IdeTestContext(Path.of(""));
return newContext(PROJECT_BASIC, null, false);
}
}

0 comments on commit 19b4d60

Please sign in to comment.