mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-11-30 00:33:56 +00:00
Use unicode.IsSpace to cover more whitespace characters
This commit is contained in:
parent
8b0d0342d4
commit
04492bab10
@ -3,6 +3,7 @@ package fzf
|
|||||||
import (
|
import (
|
||||||
"math"
|
"math"
|
||||||
"sort"
|
"sort"
|
||||||
|
"unicode"
|
||||||
|
|
||||||
"github.com/junegunn/fzf/src/curses"
|
"github.com/junegunn/fzf/src/curses"
|
||||||
"github.com/junegunn/fzf/src/util"
|
"github.com/junegunn/fzf/src/util"
|
||||||
@ -62,7 +63,7 @@ func buildResult(item *Item, offsets []Offset, score int, trimLen int) *Result {
|
|||||||
for idx := 0; idx < numChars; idx++ {
|
for idx := 0; idx < numChars; idx++ {
|
||||||
r := item.text.Get(idx)
|
r := item.text.Get(idx)
|
||||||
whitePrefixLen = idx
|
whitePrefixLen = idx
|
||||||
if idx == minBegin || r != ' ' && r != '\t' {
|
if idx == minBegin || !unicode.IsSpace(r) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package util
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"unicode"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -63,7 +64,7 @@ func (chars *Chars) TrimLength() int {
|
|||||||
len := chars.Length()
|
len := chars.Length()
|
||||||
for i = len - 1; i >= 0; i-- {
|
for i = len - 1; i >= 0; i-- {
|
||||||
char := chars.Get(i)
|
char := chars.Get(i)
|
||||||
if char != ' ' && char != '\t' {
|
if !unicode.IsSpace(char) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,7 +76,7 @@ func (chars *Chars) TrimLength() int {
|
|||||||
var j int
|
var j int
|
||||||
for j = 0; j < len; j++ {
|
for j = 0; j < len; j++ {
|
||||||
char := chars.Get(j)
|
char := chars.Get(j)
|
||||||
if char != ' ' && char != '\t' {
|
if !unicode.IsSpace(char) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,7 +87,7 @@ func (chars *Chars) TrailingWhitespaces() int {
|
|||||||
whitespaces := 0
|
whitespaces := 0
|
||||||
for i := chars.Length() - 1; i >= 0; i-- {
|
for i := chars.Length() - 1; i >= 0; i-- {
|
||||||
char := chars.Get(i)
|
char := chars.Get(i)
|
||||||
if char != ' ' && char != '\t' {
|
if !unicode.IsSpace(char) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
whitespaces++
|
whitespaces++
|
||||||
|
Loading…
Reference in New Issue
Block a user