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

[REPL] fix incorrectly cleared line after completions accepted #53662

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Changes from all commits
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
11 changes: 7 additions & 4 deletions stdlib/REPL/src/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -479,14 +479,12 @@ prompt_string(f::Function) = Base.invokelatest(f)
function maybe_show_hint(s::PromptState)
isa(s.hint, String) || return nothing
# 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)
cmove_left(terminal(s), textwidth(s.hint))
s.hint = "" # being "" signals to do one clear line remainder to clear the hint next time if still empty
s.hint = "" # being "" signals to do one clear line remainder to clear the hint next time the screen is refreshed
end
return nothing
end
Expand All @@ -496,8 +494,13 @@ function refresh_multi_line(s::PromptState; kw...)
close(s.refresh_wait)
s.refresh_wait = nothing
end
if s.hint isa String
# clear remainder of line which is unknown here if it had a hint before unbeknownst to refresh_multi_line
# the clear line cannot be printed each time because it would break column movement
print(terminal(s), "\e[0K")
end
r = refresh_multi_line(terminal(s), s; kw...)
maybe_show_hint(s)
maybe_show_hint(s) # now maybe write the hint back to the screen
return r
end
refresh_multi_line(s::ModeState; kw...) = refresh_multi_line(terminal(s), s; kw...)
Expand Down