-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add repl tab complete hints while typing #51229
Add repl tab complete hints while typing #51229
Conversation
Very nice. I had to watch the video to understand what you mean. Maybe the title of "Add an inline preview of tab complete hints to the REPL" would more clearly identify what this does. |
72dda46
to
7c9f75d
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This looks great! We probably need though a way to opt-out via something like |
Agreed. I also think that after the public api mechanism merges hints should maybe only show up for public names, even if tab completes for all. But that's more opinionated and for later. Or maybe private names show up in a different color and after a delay.. |
de9a705
to
c07ef6b
Compare
This comment was marked as resolved.
This comment was marked as resolved.
c07ef6b
to
c148b71
Compare
c148b71
to
f1d61f7
Compare
# The hint being "" then nothing is used to first clear a previous hint, then skip printing the hint | ||
# the clear line cannot be printed each time because it breaks column movement | ||
if isempty(s.hint) | ||
print(terminal(s), "\e[0K") # clear remainder of line which had a hint |
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 am experiencing frequent REPL corruption now where I lose part of the line or it prints wrong. For example, if you type
julia> using Cthu, REPL
then mouse back and change that to
julia> using Cthulhu, REPL
when you start typing, it will garble the rest of the line. Then when you type the final u
, the line gets fully deleted. Once you type another character, then it gets restored correctly.
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 have a fix ready. Basically it limits to only doing hints for the end of the line. Inserting hints at earlier positions would take a lot of work in the printing logic I think so best to just limit it for now.
Maybe it's possible to implement earlier hints before 1.11 is out.
Also I'm considering not hinting on single characters, given x
shows xor
as a hint which is a bit awkward.
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.
That seems useful. Could you also make the hint print with light colors?
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.
It already prints in :light_black
which seems like the right choice?
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.
Oh, I see, I am using TERM=screen-256color
and I don't have the terminal file for that (only for screen-256color-s
with an added status line feature), so Julia is not printing any colors for me
I've not used Julia 1.11 a lot yet, but I just disabled this feature. Might be worth canvasing folks before release to figure out whether this should be enabled by default. Maybe the NEWS should also list more complete options for people who use multiple Julia versions, e.g., "Put this in your using REPL
if isdefined(Base, :active_repl_options) && Base.active_repl != nothing && hasfield(REPL.Options, :hint_tab_completes)
Base.active_repl.options.hint_tab_completes = false
end |
Oof that does require a lot of conditionals to turn off in previous versions.. maybe we should add an env var.. If you don't mind, could you elaborate why you want to disable this? I've not heard of anyone doing so (and the convoluted way you have to do so in startup.jl makes me wonder if anyone else actually has), so the feedback would be helpful. |
Not 100% sure I know why I don't like it, but it feels "laggy." I'm not sure whether it lags the keyboard, or whether the sudden appearance of visual stimuli lags my brain. Subjectively it makes the REPL experience feel like it stutters. I tend to like the tab completions in VSCode and elsewhere, so I don't think it's just me being anti-completion. As for why I might be different, I haven't looked at how this is implemented and thus how deep the search goes, but one thing to know is that I have two registries, General and HolyLab. Any chance that's more than a red herring? |
I have those registries plus another and it's lag free for me. Linux? Master commit? |
julia> versioninfo()
Julia Version 1.11.0-DEV.1351
Commit 47d31acd14* (2024-01-22 09:46 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 16 × 12th Gen Intel(R) Core(TM) i7-1260P
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, alderlake)
Threads: 1 default, 0 interactive, 1 GC (on 16 virtual cores)
Environment:
JULIA_IMAGE_THREADS = 4 It's actually WSL. Windows seems slow at file operations, maybe that's part of it? |
Oh, also funny: since I am working on SnoopCompile I was using |
Ah yes. The If you get a chance to try julia on a native system, could you see if it's still something you'd want to disable? Also a screen recording would help understand. I've tried to set up WSL for testing but I only have access to a Windows VM, and WSL in a windows vm on an apple silicon Mac doesn't even load julia for me |
Windows |
For disabling this in startup.jl perhaps this is the simplest for now (until we set up a Preferences approach)
|
Tab complete hints show automatically as you type, then use tab to complete.
(I'm typing slower here to illustrate it. It's very responsive for me and appears adequately baked into the sysimage)
Screen.Recording.2023-09-08.at.10.01.22.AM.mov
TODO