diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2016-11-29 13:04:33 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2016-11-29 13:14:14 +1000 |
commit | 4fba067fc845551041b8f32b82268ecdd5d6f757 (patch) | |
tree | fad9cb4f05be35ac5bd214bcc4b8418eb27c6b09 | |
parent | 2e2176edc40c20dd2a3026faafc47d4aeb0a429d (diff) | |
parent | 57290a1c72d4565892f3595d9d8c3fba1086ec6b (diff) | |
download | scala-4fba067fc845551041b8f32b82268ecdd5d6f757.tar.gz scala-4fba067fc845551041b8f32b82268ecdd5d6f757.tar.bz2 scala-4fba067fc845551041b8f32b82268ecdd5d6f757.zip |
Merge commit '57290a1' into topic/merge-2.11.x-to-2.12.x-20161129
Conflicts:
spec/_layouts/default.yml
test/junit/scala/tools/nsc/interpreter/CompletionTest.scala
Fixes scala/scala-dev#272
-rw-r--r-- | spec/_layouts/default.yml | 4 | ||||
-rw-r--r-- | src/interactive/scala/tools/nsc/interactive/Global.scala | 3 | ||||
-rw-r--r-- | test/junit/scala/tools/nsc/interpreter/CompletionTest.scala | 8 |
3 files changed, 12 insertions, 3 deletions
diff --git a/spec/_layouts/default.yml b/spec/_layouts/default.yml index 06d8c1c118..983d4e56ae 100644 --- a/spec/_layouts/default.yml +++ b/spec/_layouts/default.yml @@ -15,9 +15,9 @@ } }); </script> - <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/2.6-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> + <script type="text/javascript" src="//cdn.mathjax.org/mathjax/2.6-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> <script src="//code.jquery.com/jquery-2.1.3.min.js"></script> - <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.2/styles/default.min.css"> + <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.2/styles/default.min.css"> <!-- need to use include to see value of page.chapter variable --> <style type="text/css"> {% include numbering.css %} diff --git a/src/interactive/scala/tools/nsc/interactive/Global.scala b/src/interactive/scala/tools/nsc/interactive/Global.scala index 715ba0d4f3..669a018f10 100644 --- a/src/interactive/scala/tools/nsc/interactive/Global.scala +++ b/src/interactive/scala/tools/nsc/interactive/Global.scala @@ -1189,7 +1189,8 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") case Nil => entered.isEmpty && matchCount > 0 case head :: tail => val enteredAlternatives = Set(entered, entered.capitalize) - head.inits.filter(_.length <= entered.length).exists(init => + val n = (head, entered).zipped.count {case (c, e) => c == e || (c.isUpper && c == e.toUpper)} + head.take(n).inits.exists(init => enteredAlternatives.exists(entered => lenientMatch(entered.stripPrefix(init), tail, matchCount + (if (init.isEmpty) 0 else 1)) ) diff --git a/test/junit/scala/tools/nsc/interpreter/CompletionTest.scala b/test/junit/scala/tools/nsc/interpreter/CompletionTest.scala index 1233e8b1cc..a216b319a8 100644 --- a/test/junit/scala/tools/nsc/interpreter/CompletionTest.scala +++ b/test/junit/scala/tools/nsc/interpreter/CompletionTest.scala @@ -185,6 +185,14 @@ class CompletionTest { checkExact(completer, "p1.p2.p3.Ping.Po")("Pong") } + @Test + def performanceOfLenientMatch(): Unit = { + val intp = newIMain() + val completer = new PresentationCompilerCompleter(intp) + val ident: String = "thisIsAReallyLongMethodNameWithManyManyManyManyChunks" + checkExact(completer, s"($ident: Int) => tia")(ident) + } + def checkExact(completer: PresentationCompilerCompleter, before: String, after: String = "")(expected: String*): Unit = { assertEquals(expected.toSet, completer.complete(before, after).candidates.toSet) } |