summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spec/_layouts/default.yml4
-rw-r--r--src/interactive/scala/tools/nsc/interactive/Global.scala3
-rw-r--r--test/junit/scala/tools/nsc/interpreter/CompletionTest.scala8
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)
}