mirror of
https://github.com/hymkor/lispect.git
synced 2026-10-26 21:49:56 -04:00
Fix: the read pointer was not advanced when target was found
This commit is contained in:
1 parent
6906ab0c4d
commit
3f48724fad
1 file changed
+6
-7
+6
-7
@@ -35,21 +35,20 @@ func NewWatcher(pty io.ReadWriter) *Watcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (W *Watcher) updateLastLine() {
|
func (W *Watcher) updateLastLine() {
|
||||||
newLinePos := strings.LastIndexByte(W.lastline, '\n')
|
|
||||||
if newLinePos >= 0 {
|
|
||||||
W.lastline = W.lastline[newLinePos+1:]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (W *Watcher) checkWords(token string, words []string) int {
|
func (W *Watcher) checkWords(token string, words []string) int {
|
||||||
W.lastline += token
|
W.lastline += token
|
||||||
for i, word := range words {
|
for i, word := range words {
|
||||||
if strings.Contains(W.lastline, word) {
|
if pos := strings.Index(W.lastline, word); pos >= 0 {
|
||||||
W.updateLastLine()
|
W.lastline = W.lastline[pos+len(word):]
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
W.updateLastLine()
|
newLinePos := strings.LastIndexByte(W.lastline, '\n')
|
||||||
|
if newLinePos >= 0 {
|
||||||
|
W.lastline = W.lastline[newLinePos+1:]
|
||||||
|
}
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user