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

Add padding to ProgressBar messages to avoid overlapping #1936

Merged
merged 2 commits into from
Dec 13, 2024

Conversation

kontura
Copy link
Contributor

@kontura kontura commented Dec 6, 2024

Add padding to fully fill the terminal_width, this is because MultiProgressBar overrides its own messages, it doesn't clear the lines. If the message is short some leftover characters could be still present after it.

The combination of adding/removing scriptlet messages and just overwriting MultiProgressBar lines is making this quite complicated.

Another approach to fix the issues could be reverting 8fbbeb2 it would make our code simpler but I think this should still be more efficient though I have not tested it.

Follow up for: #1925

Add padding to fully fill the terminal_width, this is because MultiProgressBar
overrides its own messages, it doesn't clear the lines.
If the message is short some leftover characters could be still present after it.
@evan-goode evan-goode self-assigned this Dec 9, 2024
// Add padding to fully fill the terminal_width, this is because MultiProgressBar
// overrides its own messages, it doesn't clear the lines.
// If the message is short some leftover characters could be still present after it.
if (message.length() < terminal_width - 4) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

message.length() does not always equal the displayed width of the message, e.g. message=もで 諤奯ゞ. I tried with 92ab80c to add support for wide characters using our existing libdnf5::cli::utils::utf8::width helper but it's not quite correct:

  1. I introduced a double free or corruption fault in the libdnf_cli tests, which seems to be triggered by calling setlocale(LC_ALL, "C.UTF-8") in ProgressbarInteractiveTest::setUp. Adding that call on the current main branch (without this PR's changes) also triggers the double free. I'm not sure what the issue is.
  2. See 92ab80c#r150174705.

Thought I would share my progress and see if you could make anything of this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also loosely connected to #1865 - trimming the message to the terminal width in the middle of a UTF multibyte character.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good point, I like your improvements.

Interestingly I cannot reproduce the double free or corruption it is working for me fine.
I tried running the libdnf5-cli tests through valgrind and apart from an unrelated versionlock_config issue I didn't see any problems.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, want to cherry-pick 92ab80c here then? Then we can see whether the Packit CI tests will reproduce the double-free.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It worked here even with you commit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, I think this is good to merge then.

@evan-goode evan-goode added this pull request to the merge queue Dec 13, 2024
Merged via the queue into rpm-software-management:main with commit f4b5ac7 Dec 13, 2024
17 checks passed
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.

3 participants