Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect MultiBar.remove behaviour #149

Open
khokm opened this issue Sep 2, 2023 · 2 comments · May be fixed by #150
Open

Incorrect MultiBar.remove behaviour #149

khokm opened this issue Sep 2, 2023 · 2 comments · May be fixed by #150

Comments

@khokm
Copy link

khokm commented Sep 2, 2023

import cliProgress from "cli-progress";

// create new container
const multibar = new cliProgress.MultiBar(
    {
        clearOnComplete: false,
        hideCursor: true,
        format: " {bar} | {filename} | {value}/{total}",
    },
    cliProgress.Presets.shades_grey
);

const b1 = multibar.create(200, 0);
const b2 = multibar.create(1000, 0);

b1.update(0, { filename: "Task 1 in progress" });
b2.update(0, { filename: "Task 2 in progress" });

setTimeout(() => {
    // Task 1 completed, remove bar.
    multibar.remove(b1);
}, 1000);

Expected behaviour:
After 1 second only 'Task 2 in progress' caption should left on screen.
Actual behaviour:
After 1 second 'Task 1 in progress' caption is still on screen, but 'Task 2 in progress' removed instead.

@khokm khokm linked a pull request Sep 2, 2023 that will close this issue
@AndiDittrich
Copy link
Member

just set clearOnComplete to true

@khokm
Copy link
Author

khokm commented Sep 9, 2023

@AndiDittrich

import cliProgress from "cli-progress";

// create new container
const multibar = new cliProgress.MultiBar(
    {
        clearOnComplete: true,
        hideCursor: true,
        format: " {bar} | {filename} | {value}/{total}",
    },
    cliProgress.Presets.shades_grey
);

const b1 = multibar.create(200, 0, { clearOnComplete: true });
const b2 = multibar.create(1000, 0, { clearOnComplete: true });

b1.update(0, { filename: "Task 1 in progress" });
b2.update(0, { filename: "Task 2 in progress" });

setTimeout(() => {
    // Task 1 completed, remove bar.
    multibar.remove(b1);
}, 1000);

Seems like nothing has changed. Btw i'm using Windows Terminal, if it matters.
clearOnComplete clears the screen only when all of the children bars are completed.
But in my case i want only one of bars to be removed, not waiting for others to complete.
I already fixed this in attached PR. Could you please merge it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants