Issue with commenting <script> tag in HTML

When commenting out a tag in HTML, CodeMirror wraps it in /* and */ instead of HTML Comments <!-- and -->. I assume the language detection is trying to comment within the script, but doesn’t take into account the cursor/highlighting position that’s still in the HTML context.

https://codemirror.net/try/#c=aW1wb3J0IHtiYXNpY1NldHVwLCBFZGl0b3JWaWV3fSBmcm9tICJjb2RlbWlycm9yIgppbXBvcnQge2h0bWx9IGZyb20gIkBjb2RlbWlycm9yL2xhbmctaHRtbCIKCm5ldyBFZGl0b3JWaWV3KHsKICBkb2M6IGA8ZG9jdHlwZSBodG1sPgo8aHRtbD4KICA8aGVhZD4KICAgIDxsaW5rIGhyZWY9Ii4vc3R5bGUuY3NzIiByZWw9InN0eWxlc2hlZXQiIC8+CiAgICA8c2NyaXB0IHNyYz0iLi9zY3JpcHQuanMiPjwvc2NyaXB0PgogIDwvaGVhZD4KPC9odG1sPmAsCiAgZXh0ZW5zaW9uczogW2Jhc2ljU2V0dXAsIGh0bWwoKV0sCiAgcGFyZW50OiBkb2N1bWVudC5ib2R5Cn0pCg==

Noting that this also happens with <style> tags

https://codemirror.net/try/#c=aW1wb3J0IHtiYXNpY1NldHVwLCBFZGl0b3JWaWV3fSBmcm9tICJjb2RlbWlycm9yIgppbXBvcnQge2h0bWx9IGZyb20gIkBjb2RlbWlycm9yL2xhbmctaHRtbCIKCm5ldyBFZGl0b3JWaWV3KHsKICBkb2M6IGA8ZG9jdHlwZSBodG1sPgo8aHRtbD4KICA8aGVhZD4KICAgIDxsaW5rIGhyZWY9Ii4vc3R5bGUuY3NzIiByZWw9InN0eWxlc2hlZXQiIC8+CiAgICA8c2NyaXB0IHNyYz0iLi9zY3JpcHQuanMiPjwvc2NyaXB0PgogICAgPHN0eWxlPjwvc3R5bGU+CiAgPC9oZWFkPgo8L2h0bWw+YCwKICBleHRlbnNpb25zOiBbYmFzaWNTZXR1cCwgaHRtbCgpXSwKICBwYXJlbnQ6IGRvY3VtZW50LmJvZHkKfSkK

That was a recent regression in @lezer/common. This patch should fix it.

1 Like

Thanks, @marijn! We’ll give that a try.

Works like a charm. Thanks for the patch!