Fix Unicode case handling (#186)

This commit is contained in:
Junegunn Choi
2015-04-14 21:45:37 +09:00
parent 319d6ced80
commit 5c25984ea0
6 changed files with 50 additions and 17 deletions

View File

@@ -4,12 +4,11 @@ import (
"regexp"
"sort"
"strings"
"unicode"
"github.com/junegunn/fzf/src/algo"
)
const uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
// fuzzy
// 'exact
// ^exact-prefix
@@ -91,7 +90,14 @@ func BuildPattern(mode Mode, caseMode Case,
switch caseMode {
case CaseSmart:
if !strings.ContainsAny(asString, uppercaseLetters) {
hasUppercase := false
for _, r := range runes {
if unicode.IsUpper(r) {
hasUppercase = true
break
}
}
if !hasUppercase {
runes, caseSensitive = []rune(strings.ToLower(asString)), false
}
case CaseIgnore: