code-hike / codehike

Marvellous code walkthroughs
https://codehike.org
MIT License
4.39k stars 135 forks source link

Link and mark annotations on the same line #385

Open pomber opened 1 year ago

pomber commented 1 year ago

Here, the link annotation is applied to the wrong part of the line

```python mark=1[7:13]
# link[2:5] #foo
print("This is Code Hike")


[Playground](https://play.codehike.org/#N4IgtgJgHiBcIB0B2zkAMMAcCeAXAFgPZIAEYAhgE4DWAvAIwDaA7LPQMwC6yAxCQDYBLJNUYAmWAFZOJHgDNChZJkrDcACgQgAKvkEBnEgZIBhQhACmJABKDqFrQEp0GVEhAAaEAGN9+uCAAdCoWAG6CFgDuALTexLjkwhaUJMAkyCRkVADmwrAkAByYUADc6UgAvp4+xHKC2XCgQkgWAHIArmAARsn+sHLk-PoWXvpEkWY4AELtuLjEcANDIyDks4QAMsLUi4PDXgQWYBYBFLjJgoPREFT2lCAVFUA)
knie20 commented 10 months ago

did some debugging on this. Narrowed the bug down to \packages\mdx\src\smooth-code\splitter.tsx > getTokenGroups function. The groups returned have faulty tokens with them.

knie20 commented 10 months ago

update.

I missed the mark the first go. The real culprit is the annotateLineTokenGroups in annotations.tsx It's a huge function that I don't fully understand yet, but it "binds" the CodeLink Component in this example to the third "group" instead of the first.

image in this image, the annotation should be in the first element in annotatedGroups, but is in the last for some reason.

PS I couldn't get the tsx mappings to work properly on the debugger for this one. Not sure if this is a next thing or tsx thing. I debugged with no mappings.