func scanLinesCr(data []byte, atEOF bool) (advance int, token []byte, err error) {
	// try just splitting like normal first
	advance, token, err = bufio.ScanLines(data, atEOF)

	// no \n or \r\n found, so try finding a \r instead
	if err != nil || advance == 0 {
		if i := bytes.IndexByte(data, '\r'); i >= 0 {
			return i + 1, data[:i], nil
		}
	}

	// i'm not sure if this will ever be true by this point tbh
	if atEOF {
		return len(data), data, nil
	}

	// no new line yet, ask for more data
	return advance, token, err
}
// scanLinesCr is bufio.ScanLines but it additionally splits on a lone CR.
//
// Pressing enter on my mac sends a CR, not a LF or CRLF. I'm not sure if this
// is platform-dependent, or if it's an xterm thing, but I think we'd want to
// split on this anyway because a shell will interpret it as a newline.
scanLinesCr is bufio.ScanLines but it additionally splits on a lone CR.

Pressing enter on my mac sends a CR, not a LF or CRLF. I'm not sure if this
is platform-dependent, or if it's an xterm thing, but I think we'd want to
split on this anyway because a shell will interpret it as a newline.
// scanLinesCr is bufio . ScanLines but it additionally splits on a lone CR . // // Pressing enter on my mac sends a CR not a LF or CRLF . I ' m not sure if this // is platform - dependent or if it ' s an xterm thing but I think we ' d want to // split on this anyway because a shell will interpret it as a newline .
func scanLinesCr(data []byte, atEOF bool) (advance int, token []byte, err error) {
	advance, token, err = bufio.ScanLines(data, atEOF)
	if err != nil || advance == 0 {
		if i := bytes.IndexByte(data, '\r'); i >= 0 {
			return i + 1, data[:i], nil
		}
	}
	if atEOF {
		return len(data), data, nil
	}
	return advance, token, err
}
func scanLinesCr ( data [ ] byte , atEOF bool ) ( advance int , token [ ] byte , err error ) { advance , token , err = bufio . ScanLines ( data , atEOF ) if err != nil || advance == 0 { if i := bytes . IndexByte ( data , '\r' ) ; i >= 0 { return i + 1 , data [ : i ] , nil } } if atEOF { return len ( data ) , data , nil } return advance , token , err }
scanLinesCr is bufio.ScanLines but it additionally splits on a lone CR.
scanLinesCr is bufio . ScanLines but it additionally splits on a lone CR .
// try just splitting like normal first // no \n or \r\n found, so try finding a \r instead // i'm not sure if this will ever be true by this point tbh // no new line yet, ask for more data