Skip to content

Conversation

doorgan
Copy link
Collaborator

@doorgan doorgan commented Apr 8, 2025

Fixes #11

Interpolations with newlines contain an :eol token in the shape of
{:eol, positions}, which get_start_pos wasn't considering, causing a
crash.

The solution I went for here is to just consider that token shape when
dealing with interpolation tokens. As far as I can see the tokens inside
the interpolation aren't being normalized, so I kept that behavior.

The test I added uses the ~S sigil instead of the helper ~q sigil. This
is due to the ~q sigil escaping the interpolation in a way that didn't
reproduce the issue I saw in an Expert release.

The code in the new test is the snippet that caused the crashes while editing
Sourceror, so to reproduce this locally it's enough to paste that into a
project and try to trigger a completion like Enum|.

Interpolations with newlines contain an `:eol` token in the shape of
`{:eol, positions}`, which `get_start_pos` wasn't considering, causing a
crash.

The solution I went for here is to just consider that token shape when
dealing with interpolation tokens. As far as I can see the tokens inside
the interpolation aren't being normalized, so I kept that behavior.

The test I added uses the `~S` sigil instead of the helper `~q` sigil. This
is due to the `~q` sigil escaping the interpolation in a way that didn't
reproduce the issue I saw in an Expert release.

The code in the new test is the snippet that caused the crashes while editing
Sourceror, so to reproduce this locally it's enough to paste that into a
project and try to trigger a completion like `Enum|`.
@scohen scohen merged commit f3dc077 into main Apr 8, 2025
14 checks passed
@scohen scohen deleted the doorgan/broken_interpolation_tokens branch April 8, 2025 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Error when getting token start position

2 participants