Skip to content

Commit

Permalink
fix JuliaLang#39982, remove cursor artifacts in REPL after JuliaLang#…
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash authored and johanmon committed Jul 5, 2021
1 parent 64c5aea commit 31f1c8b
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions stdlib/REPL/src/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -786,25 +786,30 @@ function edit_insert(s::PromptState, c::StringLike)
after = options(s).auto_refresh_time_delay
termbuf = terminal(s)
w = width(termbuf)
delayup = !eof(buf) || old_wait
offset = s.ias.curs_row == 1 || s.indent < 0 ?
sizeof(prompt_string(s.p.prompt)::String) : s.indent
offset += position(buf) - beginofline(buf) # size of current line
spinner = true
if offset + textwidth(str) <= w
spinner = '\0'
delayup = !eof(buf) || old_wait
if offset + textwidth(str) <= w && !(after == 0 && delayup)
# Avoid full update when appending characters to the end
# and an update of curs_row isn't necessary (conservatively estimated)
write(termbuf, str)
spinner = false
spinner = ' ' # temporarily clear under the cursor
elseif after == 0
refresh_line(s)
delayup = false
else
else # render a spinner for each key press
if old_wait || length(str) != 1
spinner = spin_seq[mod1(position(buf) - w, length(spin_seq))]
else
spinner = str[end]
end
delayup = true
end
if delayup
if spinner
write(termbuf, spin_seq[mod1(position(buf) - w, length(spin_seq))])
if spinner != '\0'
write(termbuf, spinner)
cmove_left(termbuf)
end
s.refresh_wait = Timer(after) do t
Expand Down

0 comments on commit 31f1c8b

Please sign in to comment.