[2.x] fix: Fixes java++ tab completion#8778
Merged
eed3si9n merged 10 commits intosbt:developfrom Feb 23, 2026
Merged
Conversation
- Limit optional-command completions after 'java++ ' to a small fixed list (-v, compile, test, run, clean, console, package) so JLine no longer prompts 'Display all 1114782 possibilities?'. - Add JavaSwitchCommandCompletions and use .examples(...) on the matched(combinedParser) token in switchParser. - Add CrossJavaTest test asserting the completion list is bounded and contains -v, compile, test. Fixes sbt#4310
…plus-completion - CrossJavaTest: use Fewer Braces for java++ completion test - Add scripted test that asserts java++ completions are bounded (<=100)
eed3si9n
approved these changes
Feb 22, 2026
sbt-app/src/sbt-test/actions/java-plus-plus-completion/build.sbt
Outdated
Show resolved
Hide resolved
Move .examples(JavaSwitchCommandCompletions*) from outside token() to inside on matched(state.combinedParser). The prior placement caused FixedSetExamples.withAddedPrefix to filter out all examples after the space character was derived, yielding zero completions after the user typed the space before the command. Remove actions/java-plus-plus-completion scripted test that called Parser.completions on the full state.combinedParser, which is too expensive and caused the CI job to timeout. The unit test in CrossJavaTest already covers the fix adequately.
eed3si9n
requested changes
Feb 23, 2026
Per review, the OOM comes from the version parser - token(StringBasic) on the right side of || has no examples constraint. Move .examples(knownVersions*) from the inner number parser to wrap the entire || expression, so both alternatives are bounded.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4310
Problem
Typing
java++(with space) and pressing Tab caused JLine to show "Display all 1114782 possibilities? (y or n)" because the optional-command argument usedmatched(state.combinedParser)with no completion limit.Solution
java++to a small fixed list:-v,compile,test,run,clean,console,package..examples(JavaSwitchCommandCompletions*)on the optional-command token inswitchParser(CrossJava.scala).CrossJavaTesttest that the completion list is bounded and contains key entries.Verification
./sbt "mainProj/Test/testOnly sbt.internal.CrossJavaTest"— all 16 tests pass (including "java++ tab completion list is bounded (Too many candidate list "java++" command tab completion #4310)").java++and Tab — completions are a short list, not "Display all N possibilities?".Root cause
optionalCommandwasParser.opt(token(Space ~> matched(state.combinedParser)));matched(combinedParser)delegates completions to the full sbt grammar, yielding millions of candidates.BasicCommands.reportParserandNetworkChannel.disconnect— cap completions via.examples(...).