Skip to content
Myr

Use unicode.IsSpace to cover more whitespace characters

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 8b0d034 · Browse files · 2 files+6 added−4 removed
This commit

State

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

Diff stats

2 files+6 added−4 removed

  • other:+6 added−4 removed

2 files+6 added−4 removed

modified:src/util/chars.go+4 added-3 removed
1package util23import (4 "unicode"5 "unicode/utf8"6)78type Chars struct {
54 unmodified lines
63 var i int64 len := chars.Length()65 for i = len - 1; i >= 0; i-- {66 char := chars.Get(i)66 if char != ' ' && char != '\t' {67 if !unicode.IsSpace(char) {68 break69 }70 }71 // Completely empty
3 unmodified lines
7576 var j int77 for j = 0; j < len; j++ {78 char := chars.Get(j)78 if char != ' ' && char != '\t' {79 if !unicode.IsSpace(char) {80 break81 }82 }83 return i - j + 1
2 unmodified lines
86func (chars *Chars) TrailingWhitespaces() int {87 whitespaces := 088 for i := chars.Length() - 1; i >= 0; i-- {89 char := chars.Get(i)89 if char != ' ' && char != '\t' {90 if !unicode.IsSpace(char) {91 break92 }93 whitespaces++94 }
63 unmodified lines
modified:src/result.go+2 added-1 removed
1 unmodified line
23import (4 "math"5 "sort"6 "unicode"78 "github.com/junegunn/fzf/src/curses"9 "github.com/junegunn/fzf/src/util"10)
51 unmodified lines
62 whitePrefixLen := 063 for idx := 0; idx < numChars; idx++ {64 r := item.text.Get(idx)65 whitePrefixLen = idx65 if idx == minBegin || r != ' ' && r != '\t' {66 if idx == minBegin || !unicode.IsSpace(r) {67 break68 }69 }70 val = util.AsUint16(minBegin - whitePrefixLen)
171 unmodified lines