Skip to content
Myr

Fix --tiebreak=pathname with non-ASCII text

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

Fix #4902

authored by Junegunn Choi · committed by Junegunn Choi · parent f7ae439 · Browse files · 3 files+29 added−3 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+29 added−3 removed

  • other:+29 added−3 removed

3 files+29 added−3 removed

modified:src/result_test.go+25 added
270 unmodified lines
271 }272 }273 }274}275276func TestPathnameTiebreak(t *testing.T) {277 // FIXME global278 sortCriteria = []criterion{byScore, byPathname}279280 score := 100281 test := func(input string, offset Offset, expected uint16) {282 for _, chars := range []util.Chars{util.ToChars([]byte(input)), util.RunesToChars([]rune(input))} {283 item := buildResult(withIndex(&Item{text: chars}, 1), []Offset{offset}, score)284 if item.points[3] != math.MaxUint16-uint16(score) || item.points[2] != expected {285 t.Error(input, item.points, expected)286 }287 }288 }289290 // Match in the file name291 test("x/foo/foo.txt", Offset{6, 9}, 1)292 // Match in the directory path293 test("x/foo/aa.txt", Offset{2, 5}, math.MaxUint16)294295 // Offsets are rune indexes, so a multi-byte character before the last296 // delimiter must not shift the delimiter position297 test("一x/foo/foo.txt", Offset{7, 10}, 1)298 test("一x/foo/aa.txt", Offset{3, 6}, math.MaxUint16)299}
modified:src/result.go+3 added-3 removed
80 unmodified lines
81 case byLength:82 val = item.TrimLength()83 case byPathname:84 if validOffsetFound {85 // Rune index, to be comparable with minBegin86 lastDelim := -186 s := item.text.ToString()87 for i := len(s) - 1; i >= 0; i-- {88 if s[i] == '/' || s[i] == '\\' {87 for i := numChars - 1; i >= 0; i-- {88 if r := item.text.Get(i); r == '/' || r == '\\' {89 lastDelim = i90 break91 }92 }
344 unmodified lines
modified:CHANGELOG.md+1 added
1 unmodified line
2=========340.74.45------6- Fixed `--tiebreak=pathname` not detecting the last path separator when the line contains a non-ASCII character before it (#4902)7- Vim plugin8 - fzf no longer blocks the editor, so live previews keep working while fzf is open9 - `fzf#run` returns an empty list when it runs fzf asynchronously. Use `sink`, `sinklist`, or `exit` to get the result10 - The popup layout now works under Zellij
3429 unmodified lines