summaryrefslogtreecommitdiffstats
path: root/src/tui
diff options
context:
space:
mode:
authorTim Cuthbertson <tim@gfxmonk.net>2018-09-27 03:35:44 +1000
committerJunegunn Choi <junegunn.c@gmail.com>2018-09-27 02:35:44 +0900
commit70a92a858a864cbbfd5c937e2ab4addbfabf8b5a (patch)
tree80d5796c26a9fb6ba7aeb91eca97076ea4e4a1c3 /src/tui
parent49d04374a429d301a375340bb9060bdd1f270b50 (diff)
Don't drop buffered input data in findOffset() (#1392)
Diffstat (limited to 'src/tui')
-rw-r--r--src/tui/light.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/tui/light.go b/src/tui/light.go
index 1098d591..83527df3 100644
--- a/src/tui/light.go
+++ b/src/tui/light.go
@@ -27,7 +27,7 @@ const (
const consoleDevice string = "/dev/tty"
-var offsetRegexp *regexp.Regexp = regexp.MustCompile("\x1b\\[([0-9]+);([0-9]+)R")
+var offsetRegexp *regexp.Regexp = regexp.MustCompile("(.*)\x1b\\[([0-9]+);([0-9]+)R")
func openTtyIn() *os.File {
in, err := os.OpenFile(consoleDevice, syscall.O_RDONLY, 0)
@@ -154,8 +154,10 @@ func (r *LightRenderer) findOffset() (row int, col int) {
for tries := 0; tries < offsetPollTries; tries++ {
bytes = r.getBytesInternal(bytes, tries > 0)
offsets := offsetRegexp.FindSubmatch(bytes)
- if len(offsets) > 2 {
- return atoi(string(offsets[1]), 0) - 1, atoi(string(offsets[2]), 0) - 1
+ if len(offsets) > 3 {
+ // add anything we skipped over to the input buffer
+ r.buffer = append(r.buffer, offsets[1]...)
+ return atoi(string(offsets[2]), 0) - 1, atoi(string(offsets[3]), 0) - 1
}
}
return -1, -1