Permalink
Browse files

Trigger case insensitive search on upper case terms

Not mixed case, but just upper case. Nobody would want to type `j FA`
(downcase and two upper-cases) just to trigger a case insensitive
search.
  • Loading branch information...
1 parent b577107 commit 677a0e97ecf77290895fcb5720b010be6051d360 @gsamokovarov committed Mar 24, 2017
Showing with 6 additions and 6 deletions.
  1. +6 −6 fuzzy/normalizer.go
View
@@ -21,8 +21,8 @@ type Normalizer struct {
//
// We apply a couple of conventions:
//
-// - If the term has different letter casing in it, do a case sensitive search.
-// By default we do a case insensitive one.
+// - If the term has capital letter , do a case sensitive search. By default
+// we do a case insensitive one to save keystrokes.
//
// - If the term contains an OS separator, we extract the very last bits of the
// path that contains that many separators. This helps us to keep the
@@ -32,7 +32,7 @@ type Normalizer struct {
// - If the term doesn't contain any OS separators, match on the base name of
// the path.
func (m Normalizer) NormalizePath(path string) string {
- if caseSensitiveSearch(m.term) {
+ if caseInsensitiveSearch(m.term) {
path = strings.ToLower(path)
}
@@ -51,7 +51,7 @@ func (m Normalizer) NormalizePath(path string) string {
// The normalization consists only of returning a case insensitive (lowered) or
// sensitive string.
func (m Normalizer) NormalizeTerm() string {
- if caseSensitiveSearch(m.term) {
+ if caseInsensitiveSearch(m.term) {
return strings.ToLower(m.term)
}
@@ -63,8 +63,8 @@ func NewNormalizer(term string) *Normalizer {
return &Normalizer{term}
}
-func caseSensitiveSearch(str string) bool {
- return strings.ToLower(str) == str || str == strings.ToUpper(str)
+func caseInsensitiveSearch(str string) bool {
+ return strings.ToLower(str) == str
}
func containsOsSeparators(str string) bool {

0 comments on commit 677a0e9

Please sign in to comment.