Skip to content

Fix counting extra lines when lines wrap #165

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

mogzol
Copy link

@mogzol mogzol commented Apr 3, 2025

Fixes #164

Previously, extra lines were counted only by the number of line breaks in them, so the number of lines cleared would be incorrect if any lines wrapped. Additionally, prevLineCount could be wrong if the size of the terminal changes between renders.

To fix this, the number of lines to clear is calculated immediately before clearing them, and the 'string-width' library is used to determine accurate widths and line counts. This is the same library used by 'wrap-ansi', so it should be reliable, and it is not actually a new dependency.

Previously, extra lines were counted only by the number of line breaks
in them, so the number of lines cleared would be incorrect if any lines
wrapped. Additionally, prevLineCount could be wrong if the size of the
terminal changes between renders.

To fix this, the number of lines to clear is calculated immediately
before clearing them, and the 'string-width' library is used to
determine accurate widths. This is the same library used by 'wrap-ansi',
so it should be reliable, and it is not actually a new dependency.
@mogzol
Copy link
Author

mogzol commented Apr 7, 2025

I also have some changes to add an option to fix #97: mogzol@cdd5547

But since they depend on these changes, I'll open another PR if/when this one gets merged

@mogzol
Copy link
Author

mogzol commented Apr 22, 2025

I made a tag in my forked repo with both this fix and the new keepOnBottom option I added so that I could use it while waiting for this PR to be reviewed. If anyone wants to try it you can install it with:

npm install --save-dev https://github.com/mogzol/webpackbar.git#7.0.0-mod

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 this pull request may close these issues.

Bar gets duplicated if a long line is printed during build
1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy