Skip to content
Myr

GoLint

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent 7833fa7 · Browse files · 3 files+19 added−22 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+19 added−22 removed

  • other:+19 added−22 removed

3 files+19 added−22 removed

modified:src/algo/algo.go+1 added
159 unmodified lines
160 }161 return trimmedLen - len(pattern), trimmedLen162}163164// EqualMatch performs equal-match165func EqualMatch(caseSensitive bool, runes []rune, pattern []rune) (int, int) {166 if len(runes) != len(pattern) {167 return -1, -1168 }
9 unmodified lines
modified:src/util/util.go+1 added-5 removed
18 unmodified lines
19 }20 return max21}2223// Max32 returns the smallest 32-bit integer23// Min32 returns the smallest 32-bit integer24func Min32(first int32, second int32) int32 {25 if first <= second {26 return first27 }
41 unmodified lines
69 }70 return val71}7273func Between(val int, min int, max int) bool {74 return val >= min && val <= max75}7673// IsTty returns true is stdin is a terminal74func IsTty() bool {75 return int(C.isatty(C.int(os.Stdin.Fd()))) != 076}
26 unmodified lines
modified:src/item.go+17 added-17 removed
35 unmodified lines
36// Tiebreak criterion to use. Never changes once fzf is started.37var rankTiebreak tiebreak3839// Rank calculates rank of the Item40func (i *Item) Rank(cache bool) Rank {41 if cache && (i.rank.matchlen > 0 || i.rank.tiebreak > 0) {42 return i.rank40func (item *Item) Rank(cache bool) Rank {41 if cache && (item.rank.matchlen > 0 || item.rank.tiebreak > 0) {42 return item.rank43 }44 matchlen := 045 prevEnd := 046 minBegin := math.MaxUint1647 for _, offset := range i.offsets {47 for _, offset := range item.offsets {48 begin := int(offset[0])49 end := int(offset[1])50 if prevEnd > begin {51 begin = prevEnd
11 unmodified lines
63 var tiebreak uint1664 switch rankTiebreak {65 case byLength:66 // It is guaranteed that .transformed in not null in normal execution67 if i.transformed != nil {67 if item.transformed != nil {68 lenSum := 069 for _, token := range i.transformed {69 for _, token := range item.transformed {70 lenSum += len(token.text)71 }72 tiebreak = uint16(lenSum)73 } else {74 tiebreak = uint16(len(i.text))74 tiebreak = uint16(len(item.text))75 }76 case byBegin:77 // We can't just look at i.offsets[0][0] because it can be an inverse term77 // We can't just look at item.offsets[0][0] because it can be an inverse term78 tiebreak = uint16(minBegin)79 case byEnd:80 if prevEnd > 0 {81 tiebreak = uint16(1 + len(i.text) - prevEnd)81 tiebreak = uint16(1 + len(item.text) - prevEnd)82 } else {83 // Empty offsets due to inverse terms.84 tiebreak = 185 }86 case byIndex:87 tiebreak = 188 }89 rank := Rank{uint16(matchlen), tiebreak, i.index}89 rank := Rank{uint16(matchlen), tiebreak, item.index}90 if cache {91 i.rank = rank91 item.rank = rank92 }93 return rank94}9596// AsString returns the original string97func (i *Item) AsString() string {98 return *i.StringPtr()97func (item *Item) AsString() string {98 return *item.StringPtr()99}100101// StringPtr returns the pointer to the original string102func (i *Item) StringPtr() *string {103 runes := i.text104 if i.origText != nil {105 runes = *i.origText102func (item *Item) StringPtr() *string {103 runes := item.text104 if item.origText != nil {105 runes = *item.origText106 }107 str := string(runes)108 return &str109}
154 unmodified lines