Skip to content

ProgressBar erases second-to-last last line of anything printed in the loop #59

@Alseidon

Description

@Alseidon

When printing anything in a loop with ProgressBars, I have the impression the new progress bar is printed by erasing the second-to-last line.
Then, any further print erases the last printed line. This has the following results for me:

julia> using ProgressBars

julia> for i in ProgressBar(1:10)
           sleep(0.2)
           println("Line $i--1")
           println("Line $i--2")
           print("Line $i--3")   # we see this line get written and then overwritten
       end
0.0%┣                                                          ┫ 0/10 [00:00<00:00, -0s/it]
Line 1--1
10.0%┣█████▎                                               ┫ 1/10 [00:00<Inf:Inf, InfGs/it]
Line 2--1
20.0%┣███████████▋                                              ┫ 2/10 [00:00<00:03, 2it/s]
Line 3--1
30.0%┣█████████████████▍                                        ┫ 3/10 [00:01<00:02, 3it/s]
Line 4--1
40.0%┣███████████████████████▏                                  ┫ 4/10 [00:01<00:02, 4it/s]
Line 5--1
50.0%┣█████████████████████████████                             ┫ 5/10 [00:01<00:01, 4it/s]
Line 6--1
60.0%┣██████████████████████████████████▉                       ┫ 6/10 [00:01<00:01, 4it/s]
Line 7--1
70.0%┣████████████████████████████████████████▋                 ┫ 7/10 [00:01<00:01, 4it/s]
Line 8--1
80.0%┣██████████████████████████████████████████████▍           ┫ 8/10 [00:02<00:00, 4it/s]
Line 9--1
90.0%┣████████████████████████████████████████████████████▏     ┫ 9/10 [00:02<00:00, 4it/s]
Line 10--1
100.0%┣████████████████████████████████████████████████████████┫ 10/10 [00:02<00:00, 4it/s]
Line 10--3
julia> for i in ProgressBar(1:10)
           sleep(0.2)
           println("Line $i--1")
       end
0.0%┣                                                          ┫ 0/10 [00:00<00:00, -0s/it]
10.0%┣█████▎                                               ┫ 1/10 [00:00<Inf:Inf, InfGs/it]
20.0%┣███████████▋                                              ┫ 2/10 [00:00<00:03, 2it/s]
30.0%┣█████████████████▍                                        ┫ 3/10 [00:01<00:02, 3it/s]
40.0%┣███████████████████████▏                                  ┫ 4/10 [00:01<00:02, 4it/s]
50.0%┣█████████████████████████████                             ┫ 5/10 [00:01<00:01, 4it/s]
60.0%┣██████████████████████████████████▉                       ┫ 6/10 [00:01<00:01, 4it/s]
70.0%┣████████████████████████████████████████▋                 ┫ 7/10 [00:01<00:01, 4it/s]
80.0%┣██████████████████████████████████████████████▍           ┫ 8/10 [00:02<00:00, 4it/s]
90.0%┣████████████████████████████████████████████████████▏     ┫ 9/10 [00:02<00:00, 4it/s]
100.0%┣████████████████████████████████████████████████████████┫ 10/10 [00:02<00:00, 4it/s]

julia> for i in ProgressBar(1:10)
           sleep(0.2)
           print("Line $i--1")
       end
100.0%┣████████████████████████████████████████████████████████┫ 10/10 [00:02<00:00, 4it/s]
Line 10--1

Not sure if it is helpful, but I am using Julia v1.11.2 with ProgressBars v1.5.1 (latest stable to date), on GNOME Terminal 3.44.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions