Skip to content

Commit 21a2602

Browse files
vtjnashKristofferC
authored and
KristofferC
committed
[REPL] fix incorrectly cleared line after completions accepted (#53662)
The hint must be cleared before the screen state is reset, otherwise the state after reset may not be compatible with being able to clear it. Fixes #52264 (cherry picked from commit 2978a64)
1 parent 15f13f7 commit 21a2602

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

stdlib/REPL/src/LineEdit.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,14 +480,12 @@ prompt_string(f::Function) = Base.invokelatest(f)
480480
function maybe_show_hint(s::PromptState)
481481
isa(s.hint, String) || return nothing
482482
# The hint being "" then nothing is used to first clear a previous hint, then skip printing the hint
483-
# the clear line cannot be printed each time because it breaks column movement
484483
if isempty(s.hint)
485-
print(terminal(s), "\e[0K") # clear remainder of line which had a hint
486484
s.hint = nothing
487485
else
488486
Base.printstyled(terminal(s), s.hint, color=:light_black)
489487
cmove_left(terminal(s), textwidth(s.hint))
490-
s.hint = "" # being "" signals to do one clear line remainder to clear the hint next time if still empty
488+
s.hint = "" # being "" signals to do one clear line remainder to clear the hint next time the screen is refreshed
491489
end
492490
return nothing
493491
end
@@ -497,8 +495,13 @@ function refresh_multi_line(s::PromptState; kw...)
497495
close(s.refresh_wait)
498496
s.refresh_wait = nothing
499497
end
498+
if s.hint isa String
499+
# clear remainder of line which is unknown here if it had a hint before unbeknownst to refresh_multi_line
500+
# the clear line cannot be printed each time because it would break column movement
501+
print(terminal(s), "\e[0K")
502+
end
500503
r = refresh_multi_line(terminal(s), s; kw...)
501-
maybe_show_hint(s)
504+
maybe_show_hint(s) # now maybe write the hint back to the screen
502505
return r
503506
end
504507
refresh_multi_line(s::ModeState; kw...) = refresh_multi_line(terminal(s), s; kw...)

0 commit comments

Comments
 (0)