소스 검색

Fixed fuzzy parsing missing logic to handle special "

Toby Chui 3 년 전
부모
커밋
e459c2f59c
1개의 변경된 파일12개의 추가작업 그리고 2개의 파일을 삭제
  1. 12 2
      mod/filesystem/fuzzy/fuzzy.go

+ 12 - 2
mod/filesystem/fuzzy/fuzzy.go

@@ -1,6 +1,7 @@
 package fuzzy
 
 import (
+	"fmt"
 	"strings"
 )
 
@@ -63,9 +64,11 @@ func buildFuzzyChunks(fuzzyInput string, caseSensitive bool) ([]string, []string
 	preciseExclude := false //Exclude precise word from buffer
 	preciseBuffer := []string{}
 
+	fmt.Println(fuzzyInput)
 	if !caseSensitive {
 		fuzzyInput = strings.ToLower(fuzzyInput)
 	}
+	fmt.Println(fuzzyInput)
 
 	fuzzyChunks := strings.Split(fuzzyInput, " ")
 	for _, thisChunk := range fuzzyChunks {
@@ -75,8 +78,15 @@ func buildFuzzyChunks(fuzzyInput string, caseSensitive bool) ([]string, []string
 			includeList = append(includeList, thisChunk[1:len(thisChunk)-1])
 		} else if len(thisChunk) > 1 && thisChunk[:1] == "-" && thisChunk[1:2] == "\"" {
 			// Example: -"asd
-			preciseExclude = true
-			preciseBuffer = append(preciseBuffer, thisChunk[2:])
+
+			if thisChunk[len(thisChunk)-1:] == "\"" {
+				//-"asd", push directly into exclude list
+				excludeList = append(excludeList, thisChunk[2:len(thisChunk)-1])
+			} else {
+				preciseExclude = true
+				preciseBuffer = append(preciseBuffer, thisChunk[2:])
+			}
+
 		} else if len(thisChunk) > 0 && thisChunk[:1] == "\"" {
 			//Starting of precise string
 			//Example (start of): "asd asd"