Skip to content

Commit

Permalink
Use try-catch not to loose cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
petvana committed Dec 29, 2022
1 parent 338b562 commit f1ec0cd
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions contrib/generate_precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,10 @@ let
end
end

function generate_precompile_statements()
ansi_enablecursor = "\e[?25h"
ansi_disablecursor = "\e[?25l"

generate_precompile_statements() = try # Make sure `ansi_enablecursor` is printed
start_time = time_ns()
debug_output = devnull # or stdout
sysimg = Base.unsafe_string(Base.JLOptions().image_file)
Expand All @@ -296,10 +299,6 @@ function generate_precompile_statements()
end

println("Collecting and executing precompile statements")

ansi_enablecursor = "\e[?25h"
ansi_disablecursor = "\e[?25l"

fancyprint && print(ansi_disablecursor)
print_state()
clock = @async begin
Expand Down Expand Up @@ -493,7 +492,6 @@ function generate_precompile_statements()
wait(clock) # Stop asynchronous printing
failed = length(statements) - n_succeeded
print_state("step3" => "F$n_succeeded ($failed failed)")
fancyprint && print(ansi_enablecursor)
println()
if have_repl
# Seems like a reasonable number right now, adjust as needed
Expand All @@ -507,7 +505,10 @@ function generate_precompile_statements()
tot_time = time_ns() - start_time
println("Precompilation complete. Summary:")
print("Total ─────── "); Base.time_print(tot_time); println()

catch e
rethrow()
finally
fancyprint && print(ansi_enablecursor)
return
end

Expand Down

0 comments on commit f1ec0cd

Please sign in to comment.