Skip to content

Commit

Permalink
Merge 15ddf93 into 46b183d
Browse files Browse the repository at this point in the history
  • Loading branch information
jaanchristensen committed Jun 21, 2020
2 parents 46b183d + 15ddf93 commit dac5b2c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
17 changes: 9 additions & 8 deletions processor/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ package processor

import (
"fmt"
str "github.com/boyter/cs/str"
"os"
"time"

str "github.com/boyter/cs/str"
)

// Returns the current time as a millisecond timestamp
Expand All @@ -32,13 +33,6 @@ func makeFuzzyDistanceOne(term string) []string {
return vals
}

// This tends to produce bad results
// Split apart so turn "test" into "t" "est" then "te" "st"
//for i := 0; i < len(term); i++ {
// vals = append(vals, term[:i])
// vals = append(vals, term[i:])
//}

// Delete letters so turn "test" into "est" "tst" "tet"
for i := 0; i < len(term); i++ {
vals = append(vals, term[:i]+term[i+1:])
Expand All @@ -51,6 +45,13 @@ func makeFuzzyDistanceOne(term string) []string {
}
}

// Replace a letter or digit which effectively does transpose for us
for i := 0; i < len(term); i++ {
for _, b := range letterDigitFuzzyBytes {
vals = append(vals, term[:i]+string(b)+term[i+1:])
}
}

// Insert a letter or digit
for i := 0; i < len(term); i++ {
for _, b := range letterDigitFuzzyBytes {
Expand Down
9 changes: 7 additions & 2 deletions processor/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ package processor

import (
"fmt"
"github.com/boyter/cs/file"
str "github.com/boyter/cs/str"
"runtime"
"strconv"
"strings"
"sync"
"time"

"github.com/boyter/cs/file"
str "github.com/boyter/cs/str"

"github.com/gdamore/tcell"
"github.com/rivo/tview"
)
Expand Down Expand Up @@ -51,6 +52,10 @@ func tuiSearch(app *tview.Application, textView *tview.TextView, searchTerm sear
tuiFileWalker.Terminate()
}

if tuiFileWalker != nil {
tuiFileWalker.Terminate()
}

// TODO still a race condition here to need to resolve as we call terminate multiple times
// We lock here because we don't want another instance to run until
// this one has terminated which should happen with the terminate call
Expand Down

0 comments on commit dac5b2c

Please sign in to comment.