shikijs / shiki-magic-move

Smoothly animated code blocks with Shiki
https://shiki-magic-move.netlify.app/
MIT License
1.11k stars 32 forks source link

Pending promises when using line numbers #11

Open mattcroat opened 2 months ago

mattcroat commented 2 months ago

The issue from #8 is back when using line numbers — the transition never starts for tokens that don't change, and thus never resolves.

https://github.com/shikijs/shiki-magic-move/assets/38083522/f2fc6e98-3990-424d-a72a-6c668abcb286

The promises log from shiki-magic-move shows the unresolved promises.

image

This is confirmed when you unfold the pending promises, and see they're the tokens that don't change.

image

paoloricciuti commented 2 months ago

@antfu we can solve this the same way we solved #8 but i wonder if there's a way during the registerTransitionEnd phase to know if the transition will start or not or at least have it "race" with some other promise that we know will resolve at the end of the process to avoid this problem once and for all.

When i was working on #9 i tried hard to think of a way to do this but i come out empty handed. If you have some ideas i think it could be a safer-for-the-future solution

paoloricciuti commented 1 month ago

I think i found a solution for this that involves element.getAnimations() will try to experiment later