Skip to content

Conversation

@reese
Copy link
Collaborator

@reese reese commented Dec 23, 2025

Closes #699

We unfortunately have to do all the indentation stripping for squiggly heredocs ourselves (see #640 for details), but the logic for this had some slight issues, which is that it was looking for the least leading whitespace of any StringNode in a heredoc. This isn't quite correct, since not every StringNode is at the beginning of a line in source -- it could be following an interpolation or might not be the left-most string node in the heredoc.

Prism does provide us with an unescaped string value, which for squiggly heredocs has the necessary leading whitespace stripped away, so we can find the indentation instead by looking at the difference between the unescaped and the content_loc values. This PR updates the indentation calculation to do that -- it looks for any StringNode with different-length unescaped vs content_loc values and uses the difference in their lengths as the leading-indentation of the heredoc.

@reese reese merged commit 9d5cc77 into trunk Dec 23, 2025
7 checks passed
@reese reese deleted the reese-heredocs branch December 23, 2025 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[prism] extra indents on variable references (?) inside heredocs

3 participants