krisk / Fuse

Lightweight fuzzy-search, in JavaScript
https://fusejs.io/
Apache License 2.0
18.44k stars 774 forks source link

Incorrect indices of matched characters #735

Closed cslee closed 6 months ago

cslee commented 1 year ago

Is there an existing issue for this?

Description of the bug

indices returned in below example contains overlapped positions

const Fuse = require('fuse.js')

const list = [
  {
    title: '/images/payment/select-payment-icon.png',
  },
]

const fuse = new Fuse(list, {
  includeMatches: true,
  keys: ['title'],
})

const result = fuse.search('images-payment-select-payment-icon')

console.log(result[0].matches[0].indices)
// Output:
// [
//   [1, 6],
//   [8, 14],
//   [16, 32],
//   [34, 34],
//   [36, 38],
//   [1, 6],
//   [8, 14],
//   [16, 34],
//   [36, 38],
// ]

The Fuse.js version where this bug is happening.

6.6.2

Is this a regression?

Which version did this behavior use to work in?

None

Steps To Reproduce

Run the script in the description

Expected behavior

indices should be matched characters starting from the first one like this:

console.log(result[0].matches[0].indices)
// Output:
// [
//   [1, 6],
//   [8, 14],
//   [16, 34],
//   [36, 38],
// ]

Screenshots

No response

Additional context

No response

FelipeTrost commented 1 year ago

I've experienced this bug as well, which resulted in the highlighted text not matching with the original value. I could provide an example if it helps.

9mm commented 11 months ago

I also have fuse highlighting like tons of letters that I havent even typed...

github-actions[bot] commented 7 months ago

This issue is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 30 days

hofmannjan1 commented 5 months ago

+1