summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2025-06-26 22:33:58 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2025-06-26 22:33:58 +0900
commit79690724d8fe0dbf785f17a49e24358e0913b5ad (patch)
tree92aa29ad3d4888defd685e8e0e5094ae59fc6674 /src
parent5ed87ffcb920f8311cfd29dee0575e6c64755314 (diff)
downloadfzf-79690724d8fe0dbf785f17a49e24358e0913b5ad.tar.gz
Fix exact boundary match with --scheme=path or --tiebreak end
Fix #4438
Diffstat (limited to 'src')
-rw-r--r--src/algo/algo.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/algo/algo.go b/src/algo/algo.go
index d6a9a663..cc855e1a 100644
--- a/src/algo/algo.go
+++ b/src/algo/algo.go
@@ -827,7 +827,7 @@ func exactMatchNaive(caseSensitive bool, normalize bool, forward bool, boundaryC
// For simplicity, only look at the bonus at the first character position
pidx := 0
- bestPos, bonus, bestBonus := -1, int16(0), int16(-1)
+ bestPos, bonus, bbonus, bestBonus := -1, int16(0), int16(0), int16(-1)
for index := 0; index < lenRunes; index++ {
index_ := indexAt(index, lenRunes, forward)
char := text.Get(index_)
@@ -849,7 +849,16 @@ func exactMatchNaive(caseSensitive bool, normalize bool, forward bool, boundaryC
bonus = bonusAt(text, index_)
}
if boundaryCheck {
- ok = bonus >= bonusBoundary
+ if forward && pidx_ == 0 {
+ bbonus = bonus
+ } else if !forward && pidx_ == lenPattern-1 {
+ if index_ < lenRunes-1 {
+ bbonus = bonusAt(text, index_+1)
+ } else {
+ bbonus = bonusBoundaryWhite
+ }
+ }
+ ok = bbonus >= bonusBoundary
if ok && pidx_ == 0 {
ok = index_ == 0 || charClassOf(text.Get(index_-1)) <= charDelimiter
}