From 1c42e6bee90b7c444e973726e01b137584dfaad5 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Wed, 9 Sep 2015 12:02:31 +1000 Subject: More liberal matching in REPL autocompletion For the SHIFT-impaired: you can just write everything in lowercase, (whisper-case?) and we'll try to DWYM. We treat capital letters that you *do* enter as significant, they can't match a lower case letter in an identifier. Modelled after IntellIJ's completion. I still don't fall into this mode if you enter an exact prefix of a candidate, but we might consider changing that. ``` scala> classOf[String].typ getAnnotationsByType getComponentType getDeclaredAnnotationsByType getTypeName getTypeParameters scala> classOf[String].typN scala> classOf[String].getTypeName res3: String = java.lang.String scala> def foo(s: str scala> def foo(s: String String StringBuffer StringBuilder StringCanBuildFrom StringContext StringFormat StringIndexOutOfBoundsException scala> def foo(s: string scala> def foo(s: String String StringBuffer StringBuilder StringCanBuildFrom StringContext StringFormat StringIndexOutOfBoundsException ``` --- test/junit/scala/tools/nsc/interpreter/CompletionTest.scala | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test') diff --git a/test/junit/scala/tools/nsc/interpreter/CompletionTest.scala b/test/junit/scala/tools/nsc/interpreter/CompletionTest.scala index a55a3c66c0..534d5ddc3a 100644 --- a/test/junit/scala/tools/nsc/interpreter/CompletionTest.scala +++ b/test/junit/scala/tools/nsc/interpreter/CompletionTest.scala @@ -62,6 +62,15 @@ class CompletionTest { checkExact(completer, "object O { class AbstractMetaFactoryFactory }; new O.AMFF")("AbstractMetaFactoryFactory") } + @Test + def lenientCamelCompletions(): Unit = { + val intp = newIMain() + val completer = new PresentationCompilerCompleter(intp) + checkExact(completer, "object O { def theCatSatOnTheMat = 1 }; import O._; tcso")("theCatSatOnTheMat") + checkExact(completer, "object O { def theCatSatOnTheMat = 1 }; import O._; sotm")("theCatSatOnTheMat") + checkExact(completer, "object O { def theCatSatOnTheMat = 1 }; import O._; TCSOTM")() + } + @Test def previousLineCompletions(): Unit = { val intp = newIMain() -- cgit v1.2.3