Skip to content

Commit

Permalink
REPL: Remove hard-coded prompt strings in favour of pre-existing cons…
Browse files Browse the repository at this point in the history
…tants (#55109)
  • Loading branch information
christiangnrd authored Jul 16, 2024
1 parent 7b0a189 commit d02bfeb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion stdlib/REPL/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ julia> ans

In Julia mode, the REPL supports something called *prompt pasting*. This activates when pasting text
that starts with `julia> ` into the REPL. In that case, only expressions starting with `julia> ` (as
well as the other REPL mode prompts: `shell> `, `help?> `, `pkg>` ) are parsed, but others are
well as the other REPL mode prompts: `shell> `, `help?> `, `pkg> ` ) are parsed, but others are
removed. This makes it possible to paste a chunk of text that has been copied from a REPL session
without having to scrub away prompts and outputs. This feature is enabled by default but can be
disabled or enabled at will with `REPL.enable_promptpaste(::Bool)`. If it is enabled, you can try it
Expand Down
2 changes: 1 addition & 1 deletion stdlib/REPL/src/Pkg_beforeload.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,5 @@ function Pkg_promptf()
end
end
# Note no handling of Pkg.offline, as the Pkg version does here
return "$(prefix)pkg> "
return "$(prefix)$(PKG_PROMPT)"
end
8 changes: 4 additions & 4 deletions stdlib/REPL/src/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ function setup_interface(
on_enter = return_callback)

# Setup help mode
help_mode = Prompt(contextual_prompt(repl, "help?> "),
help_mode = Prompt(contextual_prompt(repl, HELP_PROMPT),
prompt_prefix = hascolor ? repl.help_color : "",
prompt_suffix = hascolor ?
(repl.envcolors ? Base.input_color : repl.input_color) : "",
Expand Down Expand Up @@ -1354,8 +1354,8 @@ function setup_interface(

shell_prompt_len = length(SHELL_PROMPT)
help_prompt_len = length(HELP_PROMPT)
jl_prompt_regex = r"^In \[[0-9]+\]: |^(?:\(.+\) )?julia> "
pkg_prompt_regex = r"^(?:\(.+\) )?pkg> "
jl_prompt_regex = Regex("^In \\[[0-9]+\\]: |^(?:\\(.+\\) )?$JULIA_PROMPT")
pkg_prompt_regex = Regex("^(?:\\(.+\\) )?$PKG_PROMPT")

# Canonicalize user keymap input
if isa(extra_repl_keymap, Dict)
Expand Down Expand Up @@ -1769,7 +1769,7 @@ function run_frontend(repl::StreamREPL, backend::REPLBackendRef)
if have_color
print(repl.stream,repl.prompt_color)
end
print(repl.stream, "julia> ")
print(repl.stream, JULIA_PROMPT)
if have_color
print(repl.stream, input_color(repl))
end
Expand Down

0 comments on commit d02bfeb

Please sign in to comment.