krisk / Fuse

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

Returned indexes are incorrect #761

Open dafi opened 4 months ago

dafi commented 4 months ago

Is there an existing issue for this?

Description of the bug

I search using includeMatches option and when the pattern contains round brackets ( or ) the returned indexes are incorrect

The Fuse.js version where this bug is happening.

7.0.0

Is this a regression?

Which version did this behavior use to work in?

7.0.0

Steps To Reproduce

I created a complete example to reproduce the issue at https://stackblitz.com/edit/vitejs-vite-ml32lm?file=main.js

As you can see in the first case the returned indexes are identical

Index 0 start 0 end 25

Index 1 start 0 end 25

In second case the index at 1 differs from start only by 1, this create incorrect results when I highlight in HTML

Index 0 start 0 end 23

Index 1 start 1 end 23

Expected behavior

I expect no duplicated indexes and start at index >= 1 always greater than previous end valuey

Screenshots

No response

Additional context

No response

github-actions[bot] commented 1 week 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