-
Notifications
You must be signed in to change notification settings - Fork 264
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
textinput: Prompt length not taken into account for width #307
Comments
@meowgorithm Can we get some clarification of what the width is meant to mean. You were the last person to touch this field so I am hoping you know the reasons behind why 😄
https://github.com/charmbracelet/bubbles/blob/master/textinput/textinput.go#L113-L116 I have two possible interpretations:
Whatever the answer is, I believe we should update the documentation clarifying this field. If there is a bug, I will put up the appropriate pull request to fix this. |
I noticed that the cursor seemed to be adding an extra space which the width calculations weren't accounting for. This also led me to discover an edge case with the view (`offset`/`offsetRight`) calculation when the cursor (`pos`) sits at the very end. Additionally, `View()` was always rendering the cursor, even when `focus` was false, which the comment suggests should not be the case. These should all be resolved, such that Width is now fully respected in both `View()` and `placeholderView()`: they should _never_ render a string that exceeds the requested width. (Well... with one caveat: I did not touch the suggestion logic, as I've never used it. I did leave a comment, however, that perhaps suggestions shouldn't even render when the component does not have focus.) Fixes charmbracelet#358, charmbracelet#307
Okay, jumping back in on this one: |
@meowgorithm Thanks for the clarification. Will close this issue as it seems everything is working as expected. |
When creating a textinput, the prompt width is added to the width of the entire textinput. This means that two text inputs with a width of 20, will have different lengths based on the length of the prompt. This is visible when adding a border.
I have an example of this bug here:
https://github.com/mikelorant/bubbles-textinput-prompt
Looking at the textinput code, it is clear that the prompt length is never subtracted from the width. I believe the width is actually shorter than it should be but I am unclear what the intended width is meant to represent.
The text was updated successfully, but these errors were encountered: