New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve tab completion and code assist in REPL #9656
Improve tab completion and code assist in REPL #9656
Conversation
bed3381
to
f2c9727
Compare
@@ -345,7 +345,8 @@ trait Positions extends api.Positions { self: SymbolTable => | |||
if (t.pos includes pos) { | |||
if (isEligible(t)) last = t | |||
super.traverse(t) | |||
} else t match { | |||
} | |||
t match { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this was a latent bug in the presentation compiler. It became apparent in the REPL completion tests after I (mostly) removed the hack of inserting __DUMMY__
at the cursor in this PR.
In erroneous code, the range position of the TypeDef
of an annotated parameter can contain the annotation itself. So we should always try traversing into .symbol.annotations.map(_.original)
.
cb974fe
to
b93e04e
Compare
Re-enable acronym-style completion, e.g. getClass.gdm` offers `getDeclaredMethod[s]`. Under JLine completion, move all filtering up in the UI layer. Reimplement scala#9510 (dealing with overloads that contain some deprecated alternatives) in the UI layer Fix completion of keyword-starting-idents (e.g. `this.for<TAB>` offers `formatted`. Register a widget on CTRL-SHIFT-T that prints the type of the expression at the cursor. A second invokation prints the desugared AST. Enable levenstien based typo matching, but disable it for short strings which IMO tends to offer confusing results. Enable levenstien based typo matching: ``` scala> scala.tools.nsc.util.EditDistance.levenshtien<TAB> scala> scala.tools.nsc.util.EditDistance.levenshtein ```
b93e04e
to
f3bce2f
Compare
@retronym this looks great (and feels great, I tried all the new behaviors) One question: you've documented (in the PR description, but also in the help text in the PR) the new "show type" feature as control-shift-T, but in my terminal (Terminal app in MacOS 11.5.1), just plain control-T works, whereas control-shift-T just beeps at me. Is that not the behavior you're experiencing? Second question: according to the JLine 3.20 release notes, they've upgraded JNA to 5.8.0: jline/jline3@8e9fc36 ; can you include that bump here, too? No other concerns before merging. |
Just retested. Both work for me. I've updated the docs to control-T. I think its okay for us to hijack this keybinding. The T=type mnemonic is nice, and the existing behaviour is pretty niche.
|
Hmm, not sure what I think about the hijacking... I actually use control-T to swap (t for transpose?) characters, I'm accustomed to that being available. Not sure how typical I am. |
I've changed it to CTRL-ALT-T. WDYT? |
Yeah that works 👍 Did you see my suggestion about the JNA version? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1bb2c1c
to
d200f2a
Compare
This comment has been minimized.
This comment has been minimized.
d200f2a
to
34f1d09
Compare
fyi @eed3si9n on the JLine version bump... not sure if there are implications for sbt |
Nice features! But I think CTRL+ALT+T is so much connected to "Start terminal" in Ubuntu and flavors so this will be a big clash. I would really suggest finding something else -- everything else would be almost less of a clash even if keystrokes are overloaded... |
does an |
I run into missing API when updating from Scala 2.13.6 to 2.13.7 - method def tryCamelStuff: Completion.Result = {
// Lenient matching based on camel case and on eliding JavaBean "get" / "is" boilerplate
val camelMatches : List[c.Member ] = r.matchingResults(c.CompletionResult.camelMatch(_)).filterNot(shouldHide)
val memberCompletions : List[String ] = camelMatches.map(_.symNameDropLocal.decoded).distinct.sorted
def allowCompletion: Boolean =
(memberCompletions.size == 1) ||
c.CompletionResult.camelMatch(r.name).apply {
val pre = longestCommonPrefix(memberCompletions)
r.name.newName(pre)
}
val memberCompletionsF: List[Completion.Candidate] =
memberCompletions.map(Completion.Simple)
if (memberCompletions.isEmpty) {
Completion.NoResult
} else if (allowCompletion) {
Completion.Result(offset - r.positionDelta, memberCompletionsF)
} else {
// XXX TODO : why is this used in the original code, but does not appear in the results?
// val empty: Completion.Candidate = new Completion.Candidate {
// def stringRep: String = ""
// } // ""
Completion.Result(offset, /* empty :: */ memberCompletionsF)
}
} do I just ditch |
This was cross compiling code for Scala 2.12 and 2.13, so I have to fork that into two :-/ |
Sciss we don't even guarantee API stability of compiler and REPL internals between minor Scala versions, let alone between major versions. So I'm sorry for the inconvenience, but I consider it normal that you might need separate 2.12-specific and 2.13-specific code from time to time. As for what can be done on the 2.13 side specifically: It's rather unexpected that anyone was even using Does it appear to you that the logic in it was removed entirely, or was it merely refactored so that it's no longer easily accessible? If the former, perhaps you could paste the logic into your own codebase. If the latter, perhaps the REPL code could be refactored to expose it again. (As for who would do the refactoring, personally I'm inclined to say "pull request welcome" to such a refactoring, but I'm not sure what Jason's own take might be.) |
Re-enable acronym-style completion, e.g.
getClass.gdm
offersgetDeclaredMethod[s]
.Under JLine completion, move all filtering up in the UI layer. Reimplement #9510 (dealing with overloads that contain some deprecated alternatives) in the UI layer
Fix completion of keyword-starting-idents (e.g.
this.for<TAB>
offersformatted
.Register a widget on CTRL-ALT-T that prints the type of the expression at the cursor. A second invocation prints the desugared AST.
Enable Levenshtein based typo matching, but disable it for short strings which IMO tends to offer confusing results.
Includes upgrade to JLine 3.20 (was 3.19)