Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[skim v2] avoid panic when cache is disabled #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cdmistman
Copy link

when i set .use_cache(false) i got a panic:

thread 'my-thread' panicked at /HOME/.cargo/registry/src/index.crates.io-6f17d22bba15001f/fuzzy-matcher-0.3.7/src/skim.rs:932:48:
already borrowed: BorrowMutError
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

i think that's because m is already an owned borrow (line 837), and same with choice_chars and pattern_chars, all of which are still owned when we get to this if

disclaimer: i didn't actually test this change (i did it in github's inline editor lmao). i can test later if desired

RobWalt added a commit to RobWalt/fuzzy-matcher that referenced this pull request Jun 29, 2024
The main problem with the old code was that all of the cache RefCells
were held for too long because of the huge scope of the `fuzzy`
function. The problem was already solved by just wrapping some of the
code with an extra scope `{` + `}`. However I chose to refactor a bit
and split the old function into 3 new ones:

- `simple_match` - was already there
- `sophisticated_match` - basically the else case of `simple_match`
- `fuzzy_inner` - a function just for the control flow of the other
  function. This also handles the cache invalidation

This should supersede the pull request lotabout#20
@RobWalt
Copy link

RobWalt commented Jun 29, 2024

I fixed this with another pull request. Nice find though and cool try to fix it through the github ui. Ngl that "lmao" made me chuckle quiet a bit. I like your energy :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants