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

Tweaks to repl tab complete hints #51321

Merged
merged 2 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
only hint for 2 chars or more
  • Loading branch information
IanButterworth committed Sep 14, 2023
commit 8743920f8797eac79ade775ea37966041ca7f30e
4 changes: 2 additions & 2 deletions stdlib/REPL/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ julia> mapfold[TAB]
mapfoldl mapfoldr
```

When a single complete tab-complete result is available at the end of an input line a hint of
the completion will show in a lighter color.
When a single complete tab-complete result is available at the end of an input line and 2 or more characters
have been typed, a hint of the completion will show in a lighter color.
This can be disabled via `Base.active_repl.options.hint_tab_completes = false`.

!!! compat "Julia 1.11"
Expand Down
1 change: 1 addition & 0 deletions stdlib/REPL/src/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ function check_for_hint(s::MIState)
return false
end
completions, partial, should_complete = complete_line(st.p.complete, st, s.active_module)::Tuple{Vector{String},String,Bool}
length(partial) < 2 && return false # Don't complete for single chars, given e.g. `x` completes to `xor`
if should_complete
if length(completions) == 1
hint = only(completions)[sizeof(partial)+1:end]
Expand Down
7 changes: 7 additions & 0 deletions stdlib/REPL/test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1700,6 +1700,13 @@ fake_repl() do stdin_write, stdout_read, repl
write(stdin_write, "\t")
s4 = readuntil(stdout_read, "readavailable") # full completion is reprinted

write(stdin_write, "\x15")
write(stdin_write, "x") # single chars shouldn't hint e.g. `x` shouldn't hint at `xor`
while LineEdit.state(repl.mistate).hint !== nothing
sleep(0.1)
end
@test LineEdit.state(repl.mistate).hint === nothing

write(stdin_write, "\x15\x04")
Base.wait(repltask)
end
Expand Down