Skip to content

Commit

Permalink
Fix extended help hint to give full line to enter (#51193)
Browse files Browse the repository at this point in the history
Before this commit, the REPL would say:

    Extended help is available with `??`

Now it will give the full line required to display extended help:

    Extended help is available with `??LazyString`

I believe that this was the intended function of the code that's already
here, because currently the `extended_help_on` constant is never used.

I've resisted the urge to pass the `line` through to `trimdocs` without
a global because I don't know why @timholy did it that way to start with
and because the smaller change makes this PR easier to review.
  • Loading branch information
cmcaine committed Sep 6, 2023
1 parent 3d88550 commit f3d50b7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions stdlib/REPL/src/docview.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,19 @@ using Unicode: normalize
helpmode(io::IO, line::AbstractString, mod::Module=Main) = :($REPL.insert_hlines($(REPL._helpmode(io, line, mod))))
helpmode(line::AbstractString, mod::Module=Main) = helpmode(stdout, line, mod)

# A hack to make the line entered at the REPL available at trimdocs without
# passing the string through the entire mechanism.
const extended_help_on = Ref{Any}(nothing)

function _helpmode(io::IO, line::AbstractString, mod::Module=Main)
line = strip(line)
ternary_operator_help = (line == "?" || line == "?:")
if startswith(line, '?') && !ternary_operator_help
line = line[2:end]
extended_help_on[] = line
extended_help_on[] = nothing
brief = false
else
extended_help_on[] = nothing
extended_help_on[] = line
brief = true
end
# interpret anything starting with # or #= as asking for help on comments
Expand Down

0 comments on commit f3d50b7

Please sign in to comment.