Glitch with readline() in VSCode?


(Ignore the code I wrote… the glitch is about the REPL)
The first time I input something for readline(), nothing happens. I have to enter my input again. And after the code is done running, a weird input not defined pops up
This seems like some known bug. Has this been fixed yet? Any good workarounds?

Also, why does VSCode stick that 0 at the end of my print statement in the REPL? That is not supposed to be there…

Whoah! I ran the code in REPL. The ‘0’ still seems to be there at the end of print statement. I thought it was a vscode glitch. what’s happening?

Is anyone seeing this!? There are 0’s in such a simple code too… WHATS HAPPENING?

This should give you a clue:

julia> println("10\r9")
90

\r does not clear the line, it only moves the cursor.

PS. In general, please don’t post screenshots. Post quoted code: Please read: make it easier to help you

My bad, sorry. But how do you clear the current line entirely then?

You could do something along the lines of

println("\r                          ")

i.e. overwriting the prvious text with spaces.

For the simple countdown example, you could use Printf:

using Printf
for n in 15:-1:1
    @printf("\r%3i",n)
    sleep(0.1)
end

Also relevant, depending on how you run your code:

using REPL.Terminals
function clear_line()
    terminal = Terminals.TTYTerminal("", stdin, stdout, stderr)
    Terminals.clear_line(terminal)
end

I came up with this code with a little research. Don’t really know how REPL.Terminals works… but this code works pretty smoothly for me, although the above suggestions work just as fine! Thank you all for them!