-
Notifications
You must be signed in to change notification settings - Fork 235
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
Unable to add right margin to an empty string #252
Comments
mikelorant
added a commit
to mikelorant/lipgloss
that referenced
this issue
Jan 26, 2024
An empty string could not have padding applied on the right side. Issue: charmbracelet#252 Signed-off-by: Michael Lorant <[email protected]>
@meowgorithm The code for I'd also like to refactor |
mikelorant
added a commit
to mikelorant/lipgloss
that referenced
this issue
Jan 26, 2024
The `padLeft` and `padRight` functions were nearly identical and could benefit from being refactored to share common code. A new function called `pad` was added that applies padding based on the sign of the amount of padding needed. A positive value applies padding to the right side while a negative value applies padding to the left side. Issue: charmbracelet#252 Signed-off-by: Michael Lorant <[email protected]>
mikelorant
added a commit
to mikelorant/lipgloss
that referenced
this issue
Jan 26, 2024
The `padLeft` and `padRight` functions were nearly identical and could benefit from being refactored to share common code. A new function called `pad` was added that applies padding based on the sign of the amount of padding needed. A positive value applies padding to the right side while a negative value applies padding to the left side. Issue: charmbracelet#252 Signed-off-by: Michael Lorant <[email protected]>
I have refactored the padding functions |
mikelorant
added a commit
to mikelorant/lipgloss
that referenced
this issue
Jan 29, 2024
The `padLeft` and `padRight` functions were nearly identical and could benefit from being refactored to share common code. A new function called `pad` was added that applies padding based on the sign of the amount of padding needed. A positive value applies padding to the right side while a negative value applies padding to the left side. Issue: charmbracelet#252 Signed-off-by: Michael Lorant <[email protected]>
mikelorant
added a commit
to mikelorant/lipgloss
that referenced
this issue
Jan 30, 2024
An empty string could not have padding applied on the right side. Issue: charmbracelet#252 Signed-off-by: Michael Lorant <[email protected]>
meowgorithm
pushed a commit
that referenced
this issue
Jan 30, 2024
An empty string could not have padding applied on the right side. Issue: #252 Signed-off-by: Michael Lorant <[email protected]>
mikelorant
added a commit
to mikelorant/lipgloss
that referenced
this issue
Jan 30, 2024
The `padLeft` and `padRight` functions were nearly identical and could benefit from being refactored to share common code. A new function called `pad` was added that applies padding based on the sign of the amount of padding needed. A positive value applies padding to the right side while a negative value applies padding to the left side. Issue: charmbracelet#252 Signed-off-by: Michael Lorant <[email protected]>
mikelorant
added a commit
to mikelorant/lipgloss
that referenced
this issue
Jan 30, 2024
The `padLeft` and `padRight` functions were nearly identical and could benefit from being refactored to share common code. A new function called `pad` was added that applies padding based on the sign of the amount of padding needed. A positive value applies padding to the right side while a negative value applies padding to the left side. Issue: charmbracelet#252 Signed-off-by: Michael Lorant <[email protected]>
mikelorant
added a commit
to mikelorant/lipgloss
that referenced
this issue
Jan 30, 2024
The `padLeft` and `padRight` functions were nearly identical and could benefit from being refactored to share common code. A new function called `pad` was added that applies padding based on the sign of the amount of padding needed. A positive value applies padding to the right side while a negative value applies padding to the left side. Issue: charmbracelet#252 Signed-off-by: Michael Lorant <[email protected]>
mikelorant
added a commit
to mikelorant/lipgloss
that referenced
this issue
Jan 30, 2024
The `padLeft` and `padRight` functions were nearly identical and could benefit from being refactored to share common code. A new function called `pad` was added that applies padding based on the sign of the amount of padding needed. A positive value applies padding to the right side while a negative value applies padding to the left side. Issue: charmbracelet#252 Signed-off-by: Michael Lorant <[email protected]>
meowgorithm
pushed a commit
that referenced
this issue
Jan 31, 2024
The `padLeft` and `padRight` functions were nearly identical and could benefit from being refactored to share common code. A new function called `pad` was added that applies padding based on the sign of the amount of padding needed. A positive value applies padding to the right side while a negative value applies padding to the left side. Issue: #252 Signed-off-by: Michael Lorant <[email protected]>
This issue has been resolved. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
When attempting to add a margin to an empty string, the width is reported as
0
.Setup
To Reproduce
I have created a repository with documentation, test application and unit tests to demonstrate this issue:
Clone the repository at: https://github.com/mikelorant/lipgloss-width
To run the tests:
Source Code
The most basic way to verify this problem is with this code:
This will output
0
.Changing
bold
totrue
changes the output to1
.Be aware that the terminal capabilities detected by
muesli/termenv
will change the outcome if the terminal cannot provide ANSI capabilities. This can be forced withexport NO_COLOR=1
when enabling bold to see how the outcome changes.Expected behavior
The expected result is
1
.The text was updated successfully, but these errors were encountered: