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

Prettify printing of a small number of completions #49284

Merged
merged 2 commits into from
May 5, 2023

Conversation

JamesWrigley
Copy link
Contributor

Previously show_completions() tended to maximize the number of columns used, and if there were few enough completions to only use one or two lines the text would be a little difficult to read. Now it tries to minimize the number of columns, and there's a minimum number of completions (multicolumn_threshold) needed before it'll start using multiple columns.

Currently multicolumn_threshold is 5, which looked good to me.

Before:

julia> first(1,\t
first(itr, n::Integer) @ Base abstractarray.jl:496  first(x::Number) @ Base number.jl:111

After:

julia> first(1,\t
first(itr, n::Integer) @ Base abstractarray.jl:496
first(x::Number) @ Base number.jl:111

How to test with Infiltrator.jl:

  1. Insert Main.@exfiltrate at the beginning of show_completions().
  2. Trigger show_completions() with julia> first(\t and remove the call to Main.@exfiltrate.
  3. Test with the variables in the safehouse:
    julia> REPL.LineEdit.show_completions(safehouse.s, safehouse.completions[1:5])
    
    first(r::StepRangeLen) @ Base range.jl:833
    first(r::LinRange) @ Base range.jl:834
    first(x::Number) @ Base number.jl:111
    first(S::Base.IdentityUnitRange) @ Base indices.jl:414
    first(iter::Base.SCartesianIndices2{K}) where K @ Base reinterpretarray.jl:259

@inkydragon inkydragon added the REPL Julia's REPL (Read Eval Print Loop) label Apr 7, 2023
@JamesWrigley JamesWrigley force-pushed the completions_printing branch from 10965ad to 6e6a157 Compare April 7, 2023 16:45
Previously show_completions() tended to maximize the number of columns used,
and if there were few enough completions to only use one or two lines the text
would be a little difficult to read. Now it tries to minimize the number of
columns, and there's a minimum number of completions needed before it'll start
using multiple columns.
@JamesWrigley JamesWrigley force-pushed the completions_printing branch from 6e6a157 to 4efdd39 Compare April 7, 2023 16:51
@JamesWrigley
Copy link
Contributor Author

Not quite sure what's going on with the failing jobs, the errors don't look related to this change 🤔

@KristofferC KristofferC added the merge me PR is reviewed. Merge when all tests are passing label May 4, 2023
@KristofferC KristofferC merged commit 08945aa into JuliaLang:master May 5, 2023
@JamesWrigley JamesWrigley deleted the completions_printing branch May 5, 2023 07:29
@DilumAluthge DilumAluthge removed the merge me PR is reviewed. Merge when all tests are passing label May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants