visualPromptLines counts the *visual* rows the textarea needs (a line that wraps to three screen rows wants a three-row textarea), via wrapRows which mirrors bubbles/textarea's wrap() (see there for the grapheme-cluster caveat). Reads DisplayValue so a chip counts as one line, not the hundreds its e
()
| 163 | } |
| 164 | |
| 165 | // visualPromptLines counts the *visual* rows the textarea needs (a line that |
| 166 | // wraps to three screen rows wants a three-row textarea), via wrapRows which |
| 167 | // mirrors bubbles/textarea's wrap() (see there for the grapheme-cluster |
| 168 | // caveat). Reads DisplayValue so a chip counts as one line, not the hundreds |
| 169 | // its expanded content would. |
| 170 | func (m *Model) visualPromptLines() int { |
| 171 | w := m.width - 4 // -2 for ta.SetWidth offset, -2 for "▌ " prompt |
| 172 | if w < 1 { |
| 173 | return 1 |
| 174 | } |
| 175 | total := 0 |
| 176 | for line := range strings.SplitSeq(m.ta.DisplayValue(), "\n") { |
| 177 | total += wrapRows(line, w) |
| 178 | } |
| 179 | if total < 1 { |
| 180 | return 1 |
| 181 | } |