-
-
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
[REPL] Confusing completion when using up arrow and TAB #52264
Comments
Replacing that final Tab press with almost any keypress (left or right arrow, ENTER, any number or letter) produces a similar result: # start by running VERSION, then type VE + Up Arrow + Tab
julia> VERSION |RSION # result of typing Space
julia> VERSIO|NRSION # result of typing Left Arrow
julia> VERSIONR|SION # result of typing Right Arrow
# result of typing Enter
julia> VERSIONRSION
ERROR: UndefVarError: `VERSIONRSION` not defined in `Main`
Suggestion: check for spelling errors or missing imports. No global of this name exists in this module. Something related happens with only the arrow keys. After typing the first few letters of the command and pressing the Up arrow, pressing Left or Right will hide all the characters after the cursor. Pressing Left or Right again will make them visible again. In each case, the final behavior is the same between release v1.9 and the master branch. Apparently, the first button press is still creating the same string as in 1.9, but now it just isn't displaying properly until another key is pressed. So maybe the string display isn't being refreshed? |
This could be an effect of the Tab completion hints. Reverting that commit (or resetting LineEdit.jl to the previous version) restores the previous behavior. |
Instead of reverting the entire commit, it is sufficient to remove the following line: diff --git a/stdlib/REPL/src/LineEdit.jl b/stdlib/REPL/src/LineEdit.jl
index 709eeaa285..c20d90e7c5 100644
--- a/stdlib/REPL/src/LineEdit.jl
+++ b/stdlib/REPL/src/LineEdit.jl
@@ -482,7 +482,6 @@ function maybe_show_hint(s::PromptState)
# 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
s.hint = nothing
else
Base.printstyled(terminal(s), s.hint, color=:light_black) However, I don't have a clear idea what was the intent behind that line originally, so removing it may not be a good idea... And I can't manage to add a proper test that works after the fix but not before. @IanButterworth, sorry for the second ping on that issue but do you have any hint regarding this? |
I think all of this would be fixed from a UX perspective by turning off tab completion when you're in the middle of an entry.. Like, it doesn't make any sense to me that pressing tab here
turns into
So just disable tab completion when not at the end of an entry? Or is there some valid reason to keep it? |
I guess one possible improvement is if you are at
and pressing tab would complete to |
I think if one presses UP to recall used entries, the cursor should be placed at the end of the prompts. Would that fix the bug? |
That makes sense for one up press but doesn't for more than that because it would need to then complete the full entry from the first up |
When the prompt is empty, and one presses the key up several times, it does place the cursor at the end of the prompt always. Maybe partial entries and empty ones should behave similarly. The REPL could place the cursor at the end remembering which part has been inserted by hand. |
The hint must be cleared before the screen state is reset, otherwise the state after reset may not be compatible with being able to clear it. Fixes #52264
The hint must be cleared before the screen state is reset, otherwise the state after reset may not be compatible with being able to clear it. Fixes #52264
Imagine this REPL session with Julia
master
,|
represents the position of the cursorIdeally last TAB shouldn't do anything, as the cursor is already at the end of the line and there's nothing to complete there.
In Julia v1.9, after pressing the up arrow the TAB key completes
to
which makes sense because you're basically completing
using Linea
, but the behaviour onmaster
is much more counterintuitive because pressing TAB the first time moves the cursor at the end of the line, so another TAB shouldn't do anything at that point.The text was updated successfully, but these errors were encountered: