MCPcopy Create free account
hub / github.com/wavetermdev/waveterm / splitOnCRLFRuns

Function splitOnCRLFRuns

cmd/wsh/cmd/wshcmd-debugterm.go:186–209  ·  view source on GitHub ↗

splitOnCRLFRuns splits s at the end of each run of \r and \n characters. Each segment includes its trailing CR/LF run. The last segment may have no such run.

(s string)

Source from the content-addressed store, hash-verified

184// splitOnCRLFRuns splits s at the end of each run of \r and \n characters.
185// Each segment includes its trailing CR/LF run. The last segment may have no such run.
186func splitOnCRLFRuns(s string) []string {
187 var result []string
188 for len(s) > 0 {
189 // find start of next CR/LF run
190 i := 0
191 for i < len(s) && s[i] != '\r' && s[i] != '\n' {
192 i++
193 }
194 if i == len(s) {
195 break
196 }
197 // consume the CR/LF run
198 j := i
199 for j < len(s) && (s[j] == '\r' || s[j] == '\n') {
200 j++
201 }
202 result = append(result, s[:j])
203 s = s[j:]
204 }
205 if len(s) > 0 {
206 result = append(result, s)
207 }
208 return result
209}
210
211func formatDebugTermDecode(data []byte) string {
212 if len(data) == 0 {

Callers 1

formatDebugTermDecodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected