krisk / Fuse

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

Incorrect indices of matched characters #735

Closed cslee closed 1 month ago

cslee commented 10 months 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 7 months 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 6 months ago

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

github-actions[bot] commented 2 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 2 weeks ago

+1