diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2015-09-03 12:50:02 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2015-09-03 14:10:41 +1000 |
commit | 3f1352f3ff16b0588b0f6e05bdb0a76b4702e431 (patch) | |
tree | 3107d48aa5b33e89d13890dc3ca5d82ba948a41d | |
parent | 7bd12e33c0545de23a2c5af4fe73fa37f2f4608b (diff) | |
download | scala-3f1352f3ff16b0588b0f6e05bdb0a76b4702e431.tar.gz scala-3f1352f3ff16b0588b0f6e05bdb0a76b4702e431.tar.bz2 scala-3f1352f3ff16b0588b0f6e05bdb0a76b4702e431.zip |
Sort completion proposals
-rw-r--r-- | src/repl/scala/tools/nsc/interpreter/PresentationCompilerCompleter.scala | 2 | ||||
-rw-r--r-- | test/junit/scala/tools/nsc/interpreter/CompletionTest.scala | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/src/repl/scala/tools/nsc/interpreter/PresentationCompilerCompleter.scala b/src/repl/scala/tools/nsc/interpreter/PresentationCompilerCompleter.scala index 56819cf08e..f6b6ff440b 100644 --- a/src/repl/scala/tools/nsc/interpreter/PresentationCompilerCompleter.scala +++ b/src/repl/scala/tools/nsc/interpreter/PresentationCompilerCompleter.scala @@ -82,7 +82,7 @@ class PresentationCompilerCompleter(intp: IMain) extends Completion with ScalaCo Completion.NoCandidates // don't offer completion if the only option has been fully typed already else { // regular completion - val memberCompletions: List[String] = matching.map(_.symNameDropLocal.decoded).distinct + val memberCompletions: List[String] = matching.map(_.symNameDropLocal.decoded).distinct.sorted Candidates(cursor + r.positionDelta, memberCompletions) } } diff --git a/test/junit/scala/tools/nsc/interpreter/CompletionTest.scala b/test/junit/scala/tools/nsc/interpreter/CompletionTest.scala index 003a138e47..75ab4c605f 100644 --- a/test/junit/scala/tools/nsc/interpreter/CompletionTest.scala +++ b/test/junit/scala/tools/nsc/interpreter/CompletionTest.scala @@ -46,6 +46,9 @@ class CompletionTest { // We exclude inherited members of the synthetic interpreter wrapper classes checkExact(completer, """asInstanceO""")() checkExact(completer, """class C { asInstanceO""")("asInstanceOf") + + // Output is sorted + assertEquals(List("prefix_aaa", "prefix_nnn", "prefix_zzz"), completer.complete("""class C { def prefix_nnn = 0; def prefix_zzz = 0; def prefix_aaa = 0; prefix_""").candidates) } @Test |