Skip to content
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

JLine: completion for : doesn't work very well #12264

Closed
SethTisue opened this issue Apr 1, 2020 · 7 comments
Closed

JLine: completion for : doesn't work very well #12264

SethTisue opened this issue Apr 1, 2020 · 7 comments

Comments

@SethTisue
Copy link
Member

@lrytz reports:

completing : shows : as an option on the first line (like scala/scala-dev#697)

Also, maybe unrelated, completing :p doesn't show any results (it should show :power and :paste).

@SethTisue SethTisue transferred this issue from scala/scala-dev Dec 8, 2020
@SethTisue SethTisue added this to the Backlog milestone Dec 8, 2020
@jxnu-liguobin
Copy link
Member

: p will show paste and power, but :p will not, if there is not have a space.

@jxnu-liguobin
Copy link
Member

Could you please tell me about the expected results? Although I know something about repl, I still don't know what the problem is when I see this issue. @SethTisue

@SethTisue
Copy link
Member Author

here is how 2.12.13 behaves; this is the desired behavior:

scala 2.12.13> :<TAB>
completions   help      h?        implicits   line   paste   quit     require   save   settings   type   warnings   
edit          history   imports   javap       load   power   replay   reset     sh     silent     kind              

scala 2.12.13> :s<TAB>
save   sh   settings   silent

scala 2.12.13> :p<TAB>
paste   power

@jxnu-liguobin
Copy link
Member

Oh. It seems that adding a space after the question mark is just like 2.12.13, which is too weird.

scala> :
completions   imports       line          power         require       settings      type
help          javap         load          quit          reset         sh            warnings
implicits     kind          paste         replay        save          silent
scala> : s
save       settings   sh         silent
scala> : p
paste   power

@SethTisue
Copy link
Member Author

yeah, off-by-one problem somewhere, I suppose?

@som-snytt
Copy link

I took a quick look, because it's been my dream to someday understand jline completion. It's like the mirage of the oasis in the desert that recedes continuously.

The completion result must include the colon. (For expression completion, the accumulator holds the current text.) With that fix:

scala> :load\
No such command ':load\'.  Type :help for help.

Jline auto-escapes the space after the command. Ha, ha. I'll spend a few minutes with it later. Possibly, the "command line parser" will handle any shell escapes and quotes. Or maybe there is a setting to turn off escapes in jline.

Worth noting that jline is built for "shell commands" and not "scala expressions". We supply the parser, but maybe other components are subject to this bias, such as completion results.

@jxnu-liguobin
Copy link
Member

The colon uses CommandParser, while the other commands use ScalaParser.
Yesterday, I tested once. There was a problem in parsing the input line if it without spaces after the colon, which led to the failure of jline in match.
Maybe it's about configuration or jline3?

jxnu-liguobin added a commit to jxnu-liguobin/scala that referenced this issue Feb 25, 2021
SethTisue added a commit to scala/scala that referenced this issue Mar 12, 2021
REPL: improve tab-completion of `:`-prefixed commands (fixes scala/bug#12264)
@dwijnand dwijnand modified the milestones: Backlog, 2.13.6 Apr 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants