Engelberg / instaparse

Eclipse Public License 1.0
2.74k stars 149 forks source link

Fixed for issue #200. Corrects positioning of '^' when error line has tabs. #201

Closed seltzer1717 closed 2 years ago

seltzer1717 commented 4 years ago

What: Marker '^' added after error line is often misaligned with error column. This is most often due to tabs.

How: 'marker' function in 'failure.cljc' has been updated. marker line is now a regex replace of the text error line where all space characters are retained and regular characters are converted to spaces.

Tests: Added failure-test.cljc containing 2 tests: 1) Tests marker function confirming tab count in marker line matches tab count of text line. 2) Test pprint-failure. See code comments.

Engelberg commented 4 years ago

Thanks for preparing this pull request. I understand why you made pprint-failure-test print to the screen while running the test, but I'd prefer not to have something that looks like an error message printing every time someone runs all the tests. Would you be willing to reformulate the test case to use with-out-str to capture the output of pprint-failure as a string and compare it to the expected result? If you don't have the time to do that, I'll still include the pull request, but will just comment out the test case. Certainly having a reformulated test case would be preferable.

If you can modify it over the next few days, I will set aside some time to cut a new release at the end of this coming week.

seltzer1717 commented 4 years ago

I'm fine if you merge in the fix. No need for the test. Sorry haven't had a chance to come back to this thread in a while.