charmbracelet / charmbracelet/bubbles

textarea/textinput: control characters in input cause misbehavior/crashes during navigation

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

Description

If I trick textarea/textinput to accept control characters in its input (most easily, by using control characters in the input of `SetValue`, but also possible via bug [#466](https://github.com/charmbracelet/bubbletea/issues/466), textarea/textinput get confused:

- the width computation for the control characters is wrong
- navigating the cursor from a line containing control characters to the previous/next line can cause the bubble to panic (because the width computation is wrong)

This is most noticeable when inserting a Tab character (ASCII 9) but some other control characters also display weird behavior.

FWIW, the patch in #214 fixes this by using the (new) function `tea.SanitizeRunes` on the input string. I'm not sure that's the best approach, but it works.

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.