charmbracelet / charmbracelet/bubbles

Option to disable word-based line wrapping in text area

Open
#690 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
8.9k
Forks
457
Avg merge
1d 18h
Merged PRs (30d)
5

Description

**Is your feature request related to a problem? Please describe.**
I have started using the text area component in my new password manager, [pago](https://github.com/dbohdan/pago). The text area applies whole-word line wrapping. If one character of the word exceeds the line width, the word is wrapped to the next line. This is common and useful for writing prose but not normally used for text-based data. It means long cryptographic tokens like the keys in the following example aren't wrapped at all. I'll illustrate this with screenshots below.
```
# created: 2024-12-18T06:42:28+00:00
# public key: age1n207up3rglzp87mwgu03ne3m4uzdxasynrqpgxwcwa5tsfvlpf2qsrfhaj
AGE-SECRET-KEY-1Z9ZU8AHM3LW4PQG8FX03TWUHFAMQYUGU0ZTWMN2787CD29D0KV9SX4H6WH
```

**Describe the solution you'd like**
I would like a setting to switch from whole-word line wrapping to breaking the word on any character the way code editors do.

**Describe alternatives you've considered**
The alternatives are to leave things as they are (this isn't a deal-breaker), fork the text area component, or replace it.

**Additional context**
Here is how the wrapping mechanism normally works.
![Screenshot with the unwrapped line.](https://github.com/user-attachments/assets/48da9933-a410-4659-9738-f9d69bb19578)
The last word gets wrapped after you add one more space.
![Screenshot with the same line wrapped.](https://github.com/user-attachments/assets/914587b7-4033-4819-8d20-1f788b22bf3a)

Here is how it fails with a long [age](https://github.com/FiloSottile/age) private key.
![before-key-long](https://github.com/user-attachments/assets/92396c60-ca33-4370-a24c-5639a2df7e5c)
The user presses Space, and the whole token is shifted down one line.
![after-key-long](https://github.com/user-attachments/assets/4107c414-f38c-425b-a3c2-14259258288f)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.