FuelLabs / sway

🌴 Empowering everyone to build reliable and efficient smart contracts.
https://docs.fuel.network/docs/sway/
Apache License 2.0
62.58k stars 5.37k forks source link

fix code snippet for old diagnostics #6507

Closed xunilrj closed 1 month ago

xunilrj commented 2 months ago

Description

This PR solves a small bug when calculating the code snippets of some diagnostics.

image

Checklist

alfiedotwtf commented 2 months ago

Just thinking, maybe a few simple tests that do the happy path and also bounds checks might be worth it so we don't introduce unwanted behaviour?

xunilrj commented 1 month ago

I have changed the algorithm to something easier to understand, more performant, given that we iterate the string only once, and I have also written more tests.