Skip to content

Commit ac40075

Browse files
committed
nil check
1 parent af77611 commit ac40075

2 files changed

Lines changed: 7 additions & 11 deletions

File tree

filter/fuzzy.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,16 @@ func (fs *fileSystem) ReadDir(name string) ([]fs.DirEntry, error) {
5555
}
5656

5757
func (f *fuzzySearch) Search(q string, option *SearchOption) ([]SearchResult, error) {
58-
var (
59-
dir string
60-
)
61-
6258
f.cachedFile = make(map[string]string, option.Limit)
6359
texts := make([]string, 0, option.Limit)
6460
results := make([]SearchResult, 0, option.Limit)
6561
isDuplicateLine := make(map[string]bool, option.Limit)
6662

67-
if option.TargetDir != "" {
68-
dir = option.TargetDir
69-
} else {
70-
dir = "."
63+
if option.TargetDir == "" {
64+
option.TargetDir = "."
7165
}
7266

73-
files, err := f.getFiles(dir, option.Limit)
67+
files, err := f.getFiles(option.TargetDir, option.Limit)
7468
if err != nil {
7569
util.Logger.Warn("get file error : ", err)
7670
return nil, err

filter/ripgrep.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
)
1414

1515
const (
16-
timeout = 100 * time.Millisecond
16+
timeout = 150 * time.Millisecond
1717
)
1818

1919
type rg struct{}
@@ -105,7 +105,9 @@ func (r *rg) Search(q string, option *SearchOption) ([]SearchResult, error) {
105105
if err != nil {
106106
continue
107107
}
108-
results = append(results, *result)
108+
if result != nil {
109+
results = append(results, *result)
110+
}
109111
}
110112
if err := ecmd.Wait(); err != nil {
111113
util.Logger.Warn("command exec wait error : ", err)

0 commit comments

Comments
 (0)