Skip to content

IDEasy complete tries to match commandlets twice #536

@jan-vcapgemini

Description

@jan-vcapgemini

Expected behavior

IDEasy complete should match commandlets only once.

Actual behavior

It appears that IDEasy matches commandlets for the completion of an expression a 2nd time.
See:

public List<CompletionCandidate> complete(CliArguments arguments, boolean includeContextOptions) {
CompletionCandidateCollector collector = new CompletionCandidateCollectorDefault(this);
if (arguments.current().isStart()) {
arguments.next();
}
if (includeContextOptions) {
ContextCommandlet cc = new ContextCommandlet();
for (Property<?> property : cc.getProperties()) {
assert (property.isOption());
property.apply(arguments, this, cc, collector);
}
}
CliArgument current = arguments.current();
if (!current.isEnd()) {
String keyword = current.get();
Commandlet firstCandidate = this.commandletManager.getCommandletByFirstKeyword(keyword);
boolean matches = false;
if (firstCandidate != null) {
matches = apply(arguments.copy(), 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);
}
}
}
}
return collector.getSortedCandidates();
}

if (!matches) {
for (Commandlet cmd : this.commandletManager.getCommandlets()) {
if (cmd != firstCandidate) {
apply(arguments.copy(), cmd, collector);
}
}
}

Steps to reproduce (bug) / Use Case of feature request (enhancement)

  1. Debug through ide complete in

Related/Dependent Issues

Comments/Hints:

Affected version:

  • IDEasy: 2024.08.001-beta-SNAPSHOT

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions