Skip to content

Commit

Permalink
Make sure fuzzy strings have fuzziness at the end
Browse files Browse the repository at this point in the history
Fixes GH olivernn#375

Before, insertions were not made at the end of a fuzzy string for
token sets
  • Loading branch information
hoelzro committed Oct 26, 2018
1 parent e705c40 commit c1e0f24
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/token_set.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ lunr.TokenSet.fromFuzzyString = function (str, editDistance) {

if (frame.str.length == 1) {
noEditNode.final = true
} else {
stack.push({
node: noEditNode,
editsRemaining: frame.editsRemaining,
str: frame.str.slice(1)
})
}

stack.push({
node: noEditNode,
editsRemaining: frame.editsRemaining,
str: frame.str.slice(1)
})
}

// deletion
Expand Down
2 changes: 2 additions & 0 deletions test/token_set_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ suite('lunr.TokenSet', function () {
x4 = lunr.TokenSet.fromString('bar'),
x5 = lunr.TokenSet.fromString('ba'),
x6 = lunr.TokenSet.fromString('foo'),
x7 = lunr.TokenSet.fromString('bara'),
y = lunr.TokenSet.fromFuzzyString('bar', 1)

assert.sameMembers(x1.intersect(y).toArray(), ["bbar"])
Expand All @@ -280,6 +281,7 @@ suite('lunr.TokenSet', function () {
assert.sameMembers(x4.intersect(y).toArray(), ["bar"])
assert.sameMembers(x5.intersect(y).toArray(), ["ba"])
assert.equal(x6.intersect(y).toArray().length, 0)
assert.sameMembers(x7.intersect(y).toArray(), ["bara"])
})

test('intersect with fuzzy string transpose', function () {
Expand Down

0 comments on commit c1e0f24

Please sign in to comment.