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

[BUG] The size of the tab is not fixed when justifying the text on "fully" #3424

Open
2 tasks done
oppZ opened this issue Jul 11, 2024 · 1 comment · May be fixed by #3425
Open
2 tasks done

[BUG] The size of the tab is not fixed when justifying the text on "fully" #3424

oppZ opened this issue Jul 11, 2024 · 1 comment · May be fixed by #3425

Comments

@oppZ
Copy link

oppZ commented Jul 11, 2024

Describe the bug

I'm coming from textual, the tui framework. I was printing paragraphs in Label and added a \t before each to add a tab. As I was resizing the window, I noticed that some paragraphs were not aligned anymore - some had extra spaces. I have set the css of that label to "text-align: justify;" to justify it fully - (from left to right).

Here is how the issue looks like :

demo

As you can see, the space of the indentation for the first paragraph changes.

I tracked down the issue and these are my findings :

In textual, \t is converted with 8 spaces and uses rich to split and justify the text
In rich, the text is split for each word using " " so a space. Problem is, the 8 spaces from textual are treated as 8 words in addition to the "real" ones. Therefore, in the current implementation when the text is justified, space are set between words, but the spaces are too.

Below is rich in debug mode of the containers.py file :

Screenshot from 2024-07-11 21-31-22

You can see that the first line is split by " " and the variable "spaces" hold the amount of spaces to append for each word. In he "spaces" variable the first "words" (spaces) have more than 1 space, therefore spaces are also considered as words.

The issue here is that the tab (\t) is converted to spaces and these spaces are justified and so the size of the tab is bigger than the default 8

What platform (Win/Linux/Mac) are you running on? What terminal software are you using?

ubunu 24.04

Copy link

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

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

Successfully merging a pull request may close this issue.

1 participant