mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-23 16:33:50 -07:00
Fix prefix/suffix/equal matcher to trim whitespaces
- Prefix matcher will trim leading whitespaces only when the pattern doesn't start with a whitespace - Suffix matcher will trim trailing whitespaces only when the pattern doesn't end with a whitespace - Equal matcher will trim leading whitespaces only when the pattern doesn't start with a whitespace, and trim trailing whitespaces only when the pattern doesn't end with a whitespace Previously, only suffix matcher would trim whitespaces unconditionally. Fix #1894
This commit is contained in:
@@ -130,6 +130,18 @@ func (chars *Chars) TrimLength() uint16 {
|
||||
return chars.trimLength
|
||||
}
|
||||
|
||||
func (chars *Chars) LeadingWhitespaces() int {
|
||||
whitespaces := 0
|
||||
for i := 0; i < chars.Length(); i++ {
|
||||
char := chars.Get(i)
|
||||
if !unicode.IsSpace(char) {
|
||||
break
|
||||
}
|
||||
whitespaces++
|
||||
}
|
||||
return whitespaces
|
||||
}
|
||||
|
||||
func (chars *Chars) TrailingWhitespaces() int {
|
||||
whitespaces := 0
|
||||
for i := chars.Length() - 1; i >= 0; i-- {
|
||||
|
Reference in New Issue
Block a user