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

HighlightState with a non-empty initial_stack crashing? #261

Open
yonilevy opened this issue Sep 10, 2019 · 2 comments
Open

HighlightState with a non-empty initial_stack crashing? #261

yonilevy opened this issue Sep 10, 2019 · 2 comments
Labels

Comments

@yonilevy
Copy link
Contributor

Hi,

I'm trying to build a HighlightState with a cached initial_stack, as described in the docs:

Alternatively you can save space by caching only the path field of this struct
then re-create the HighlightState when needed by passing that stack as the initial_stack
parameter to the new method. This takes less space but a small amount of time to re-create the style stack.

I'm probably missing something (very new to rust), but to me it appears this is guaranteed to crash:
The first call to update_single_cache_for_push in HighlightState::new, will pass path of length 0, which results in path.len() - 1 panicking with attempt to subtract with overflow.

Is there an example somewhere of code using HighlightState with a non-empty initial_stack? What am I missing?

Thanks ahead, and many thanks for building this incredible library!

@keith-hall
Copy link
Collaborator

Hi, thanks for reporting. It's possible that there are currently no unit tests covering this scenario, and that you are the first person to try using it...
I will investigate when I'm able to make time, but maybe someone else will beat me to it :)

@trishume
Copy link
Owner

Yup seems right, this path indeed doesn't seem to be tested. I might look into it this weekend if I have time, but no guarantees.

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

No branches or pull requests

4 participants