Skip to content

Commit

Permalink
don't show autocompletes if signature of name is already shown
Browse files Browse the repository at this point in the history
  • Loading branch information
Li Haoyi committed Apr 13, 2015
1 parent c825638 commit cd64d73
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
11 changes: 9 additions & 2 deletions repl/src/main/scala/ammonite/repl/frontend/JLineFrontend.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,15 @@ object JLineFrontend{
cursor,
buf
)
candidates.addAll(completions)
signatures = sigs
if (!completions.isEmpty) {
candidates.addAll(completions.sorted)
signatures = sigs.sorted
} else if (!sigs.isEmpty){
println()
sigs.foreach(reader.println)
reader.drawLine()
}

completionBase
}

Expand Down
5 changes: 3 additions & 2 deletions repl/src/main/scala/ammonite/repl/interp/Pressy.scala
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ object Pressy {

val run = new Run(pressy, currentFile, allCode, index)

val (i, all) = run.dotted.headOption orElse run.prefixed.headOption getOrElse run.scoped(index)
val (i, all) =
run.dotted.headOption orElse run.prefixed.headOption getOrElse run.scoped(index)

val allNames = all.map(_._1).filter(_ != "<init>")
val allNames = all.collect{ case (name, None) => name}.filter(_ != "<init>")
val signatures = all.collect{ case (name, Some(defn)) => defn }

(i - prefix.length, allNames, signatures)
Expand Down
7 changes: 6 additions & 1 deletion repl/src/test/scala/ammonite/repl/AutocompleteTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@ object AutocompleteTests extends TestSuite{
complete("""Seq(1, 2, 3).map(argNameLol => <caret>)""", Set("argNameLol") -- _)
complete("""object Zomg{ <caret> }""", Set("Zomg") -- _)
complete(
"println<caret>",
"printl<caret>",
Set("println") ^,
Set[String]() ^
)
complete(
"println<caret>",
Set[String]() ^,
Set("def println(x: Any): Unit", "def println(): Unit") ^
)
}
Expand Down

0 comments on commit cd64d73

Please sign in to comment.