Copilot commented on code in PR #15367:
URL: https://github.com/apache/grails-core/pull/15367#discussion_r2748779823
##########
grails-shell-cli/src/main/groovy/org/grails/cli/profile/commands/HelpCommand.groovy:
##########
@@ -113,20 +116,20 @@ grails [environment]* [target] [arguments]*'
}
@Override
- int complete(String buffer, int cursor, List<CharSequence> candidates) {
+ void complete(LineReader reader, ParsedLine line, List<Candidate>
candidates) {
def allCommands = findAllCommands().collect() { CommandDescription
desc -> desc.name }
+ String buffer = line.word()
for (cmd in allCommands) {
if (buffer) {
if (cmd.startsWith(buffer)) {
- candidates << cmd.substring(buffer.size())
+ candidates.add(new Candidate(cmd))
}
}
else {
- candidates << cmd
+ candidates.add(new Candidate(cmd))
}
}
Review Comment:
The completion logic could be simplified. Since JLine 3's Candidate expects
full values (not suffixes like JLine 2), both branches add the same full
command name to candidates. The if/else structure checking whether buffer is
empty/null is unnecessary - you could iterate once and add all matching
commands (startsWith check handles empty/null buffers correctly as they'd match
all commands).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]