[prism] Fix comment check for expression-led call chains#786
Merged
Conversation
froydnj
approved these changes
Jan 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I was writing the test cases I promised in #770 but found several edge cases that either formatted incorrectly or were simply not idempotent over multiple formats. This PR adds a bunch of fixtures around this particular scenario (call chains starting with expressions and comments between/around the first caller). Ripper has almost the same behavior, though it has the same idempotency issues that this intends to resolve, so I've made this a Prism-only test case.
The specific change in logic is that previously we were only checking for comments between the end of the leading expression and the dot-operator, like this:
But really, the check is trying to look for any comment that would actually render in that space. This means that in the comment above, we actually don't care about that comment (because it will always get shifted inside the closing brace), but it also means we do care about comments that would render there, such as trailing comments that might be outside of the call chain proper, such as