bubbles icon indicating copy to clipboard operation
bubbles copied to clipboard

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

Open knz opened this issue 3 years ago • 1 comments
trafficstars

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, 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.

knz avatar Oct 02 '22 18:10 knz

Note: this issue is compounded (and can be made worse) by https://github.com/charmbracelet/lipgloss/issues/108

knz avatar Oct 05 '22 14:10 knz