Skip to content

Commit

Permalink
fix(keytracker): remove non-working pattern matching code
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuar committed Oct 19, 2023
1 parent ab0c431 commit e495f1b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 41 deletions.
10 changes: 3 additions & 7 deletions internal/keytracker/keytracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,12 @@ type KeyTracker struct {

func (kt *KeyTracker) slurpWords(wordCh chan *Correction, stats stats) {
charBuf := new(bytes.Buffer)
patternBuf := newPatternBuf(3)
log.Debug().Msg("Slurping words...")
for k := range kt.kbdEvents {
if kt.paused {
continue
}
if k.IsKeyRelease() {
patternBuf.write(k.AsRune)
if patternBuf.match(". ") {
kt.kbd.TypeBackspace()
}
switch {
case k.IsBackspace():
// backspace key
Expand All @@ -71,22 +66,23 @@ func (kt *KeyTracker) slurpWords(wordCh chan *Correction, stats stats) {
charBuf.Truncate(charBuf.Len() - 1)
}
case k.AsRune == '\n' || unicode.IsControl(k.AsRune):
stats.IncKeyCounter()
// newline or control character, reset the buffer
charBuf.Reset()
case unicode.IsPunct(k.AsRune), unicode.IsSymbol(k.AsRune), unicode.IsSpace(k.AsRune):
stats.IncKeyCounter()
// a punctuation mark, which would indicate a word has been typed, so handle that
//
// most other punctuation should indicate end of word, so
// handle that
stats.IncKeyCounter()
if charBuf.Len() > 0 {
wordCh <- NewCorrection(charBuf.String(), "", k.AsRune)
charBuf.Reset()
}
default:
stats.IncKeyCounter()
// case unicode.IsDigit(k.AsRune), unicode.IsLetter(k.AsRune):
// a letter or number
stats.IncKeyCounter()
_, err := charBuf.WriteRune(k.AsRune)
if err != nil {
log.Debug().Caller().Err(err).
Expand Down
34 changes: 0 additions & 34 deletions internal/keytracker/pattern.go

This file was deleted.

0 comments on commit e495f1b

Please sign in to comment.