shouldChip collapses a paste when either its line count or char count clears the threshold: lines catch multi-line pastes, chars catch single-line blobs.
(s string)
| 198 | // shouldChip collapses a paste when either its line count or char count clears |
| 199 | // the threshold: lines catch multi-line pastes, chars catch single-line blobs. |
| 200 | func shouldChip(s string) bool { |
| 201 | if countLines(s) >= pasteChipMinLines { |
| 202 | return true |
| 203 | } |
| 204 | return utf8.RuneCountInString(s) >= pasteChipMinChars |
| 205 | } |
| 206 | |
| 207 | // countLines returns a paste's visual line count. Terminals disagree on |
| 208 | // separators (\n unix, \r old-mac, \r\n Windows); max of the \n and \r counts |