Skip to content

Commit

Permalink
nil check
Browse files Browse the repository at this point in the history
  • Loading branch information
tjmtmmnk committed Mar 1, 2021
1 parent af77611 commit ac40075
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
12 changes: 3 additions & 9 deletions filter/fuzzy.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,16 @@ func (fs *fileSystem) ReadDir(name string) ([]fs.DirEntry, error) {
}

func (f *fuzzySearch) Search(q string, option *SearchOption) ([]SearchResult, error) {
var (
dir string
)

f.cachedFile = make(map[string]string, option.Limit)
texts := make([]string, 0, option.Limit)
results := make([]SearchResult, 0, option.Limit)
isDuplicateLine := make(map[string]bool, option.Limit)

if option.TargetDir != "" {
dir = option.TargetDir
} else {
dir = "."
if option.TargetDir == "" {
option.TargetDir = "."
}

files, err := f.getFiles(dir, option.Limit)
files, err := f.getFiles(option.TargetDir, option.Limit)
if err != nil {
util.Logger.Warn("get file error : ", err)
return nil, err
Expand Down
6 changes: 4 additions & 2 deletions filter/ripgrep.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

const (
timeout = 100 * time.Millisecond
timeout = 150 * time.Millisecond
)

type rg struct{}
Expand Down Expand Up @@ -105,7 +105,9 @@ func (r *rg) Search(q string, option *SearchOption) ([]SearchResult, error) {
if err != nil {
continue
}
results = append(results, *result)
if result != nil {
results = append(results, *result)
}
}
if err := ecmd.Wait(); err != nil {
util.Logger.Warn("command exec wait error : ", err)
Expand Down

0 comments on commit ac40075

Please sign in to comment.