pointfreeco / swift-snapshot-testing

📸 Delightful Swift snapshot testing.
https://www.pointfree.co/episodes/ep41-a-tour-of-snapshot-testing
MIT License
3.68k stars 556 forks source link

Fix indentation parsing #830

Closed stephencelis closed 5 months ago

stephencelis commented 5 months ago

Inline snapshot testing attempts to figure out the indentation width of a file by finding the first line with whitespace and grabbing the prefix of whitespace. While this works fine if you trim whitespace from whitespace-only lines, it breaks if you do not, because a line of the form:

"    \n"

Will currently match in its entirety and incorporate the newline into the indentation.

This PR fixes this by picking the first indented line that contains non-whitespace characters, instead.