mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-07 15:42:08 -07:00
Fix Transform result cache to speed up subsequent searches
This commit is contained in:
@@ -86,19 +86,25 @@ func TestCaseSensitivity(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOrigText(t *testing.T) {
|
||||
func TestOrigTextAndTransformed(t *testing.T) {
|
||||
strptr := func(str string) *string {
|
||||
return &str
|
||||
}
|
||||
|
||||
pattern := BuildPattern(MODE_EXTENDED, CASE_SMART, []Range{}, nil, []rune("jg"))
|
||||
tokens := Tokenize(strptr("junegunn"), nil)
|
||||
trans := Transform(tokens, []Range{Range{1, 1}})
|
||||
|
||||
for _, fun := range []func(*Chunk) []*Item{pattern.fuzzyMatch, pattern.extendedMatch} {
|
||||
chunk := Chunk{
|
||||
&Item{text: strptr("junegunn"), origText: strptr("junegunn.choi")},
|
||||
&Item{
|
||||
text: strptr("junegunn"),
|
||||
origText: strptr("junegunn.choi"),
|
||||
transformed: trans},
|
||||
}
|
||||
matches := fun(&chunk)
|
||||
if *matches[0].text != "junegunn" || *matches[0].origText != "junegunn.choi" ||
|
||||
matches[0].offsets[0][0] != 0 || matches[0].offsets[0][1] != 5 {
|
||||
matches[0].offsets[0][0] != 0 || matches[0].offsets[0][1] != 5 ||
|
||||
matches[0].transformed != trans {
|
||||
t.Error("Invalid match result", matches)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user