Skip to content
Myr

Don't drop buffered input data in findOffset() (#1392)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tim Cuthbertson · committed by Junegunn Choi · parent 49d0437 · Browse files · 1 file+5 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+5 added−3 removed

  • other:+5 added−3 removed

1 file+5 added−3 removed

modified:src/tui/light.go+5 added-3 removed
25 unmodified lines
26)2728const consoleDevice string = "/dev/tty"2930var offsetRegexp *regexp.Regexp = regexp.MustCompile("\x1b\\[([0-9]+);([0-9]+)R")30var offsetRegexp *regexp.Regexp = regexp.MustCompile("(.*)\x1b\\[([0-9]+);([0-9]+)R")3132func openTtyIn() *os.File {33 in, err := os.OpenFile(consoleDevice, syscall.O_RDONLY, 0)34 if err != nil {
118 unmodified lines
153 bytes := []byte{}154 for tries := 0; tries < offsetPollTries; tries++ {155 bytes = r.getBytesInternal(bytes, tries > 0)156 offsets := offsetRegexp.FindSubmatch(bytes)157 if len(offsets) > 2 {158 return atoi(string(offsets[1]), 0) - 1, atoi(string(offsets[2]), 0) - 1157 if len(offsets) > 3 {158 // add anything we skipped over to the input buffer159 r.buffer = append(r.buffer, offsets[1]...)160 return atoi(string(offsets[2]), 0) - 1, atoi(string(offsets[3]), 0) - 1161 }162 }163 return -1, -1164}
776 unmodified lines