REPL: JLine 3: improve tab completion behavior#8905
Merged
SethTisue merged 2 commits intoscala:2.13.xfrom Apr 22, 2020
Merged
Conversation
1749a23 to
b49a9f4
Compare
This was referenced Apr 22, 2020
b49a9f4 to
5eb5124
Compare
som-snytt
approved these changes
Apr 22, 2020
Contributor
som-snytt
left a comment
There was a problem hiding this comment.
Your "Vissi d'arte" moment if there ever was one.
Contributor
|
|
lrytz
approved these changes
Apr 22, 2020
Member
lrytz
left a comment
There was a problem hiding this comment.
A few small questions. run/repl-completions.scala needs an update-check.
Member
Author
actually that's a real regression in how |
no specific motivation, it just seems likely that we'll want bugfixes. I don't see anything in the changelog that looks alarming (though also nothing specifically appealing)
5eb5124 to
ee2b5ae
Compare
Member
Author
|
final fix was --- src/repl-frontend/scala/tools/nsc/interpreter/shell/ILoop.scala
+++ src/repl-frontend/scala/tools/nsc/interpreter/shell/ILoop.scala
@@ -550,14 +550,17 @@ class ILoop(config: ShellConfig, inOverride: BufferedReader = null,
// it's also used by ReplTest
def completionsCommand(what: String): Result = {
val completions = in.completion.complete(what, what.length)
- if (completions.candidates.nonEmpty) {
+ val candidates = completions.candidates.filterNot(_.isUniversal)
+ // condition here is a bit weird because of the weird hack we have where
+ // the first candidate having an empty defString means it's not really
+ // completion, but showing the method signature instead
+ if (candidates.headOption.exists(_.defString.nonEmpty)) {
val prefix =
if (completions == NoCompletions) ""
else what.substring(0, completions.cursor)
// hvesalai (emacs sbt-mode maintainer) says it's important to echo only once and not per-line
echo(
- completions.candidates
- .map(c => s"[completions] $prefix$c")
+ candidates.map(c => s"[completions] $prefix${c.defString}")
.mkString("\n")
)
} |
Contributor
|
I feel like a Tab Hunter pun is warranted. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes scala/scala-dev#698