Repository navigation
Conversation
Fixes ruby#1037. When a method is defined in a file with CRLF line endings, show_source displayed a ^M at the end of every line, because SourceFinder read the file content verbatim. The code listing shown when a session starts (and by whereami) had the same problem in WorkSpace#code_around_binding. Normalize CRLF to LF when reading the file in SourceFinder::Source and before colorizing in WorkSpace#code_around_binding. Line numbers are unaffected.
This branch has not been deployed
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.
Fixes #1037.
When a method is defined in a file with CRLF line endings,
show_sourcedisplayed a^Mat the end of every line:The parser treats CR as whitespace, but the source was read from the file verbatim and colorized as-is.
The same happened in the code listing shown when a session starts on
binding.irb(and inwhereami), which comes fromWorkSpace#code_around_binding.This change normalizes CRLF to LF in the two places that read source code for display:
IRB::SourceFinder::Source#file_content(used byshow_source)WorkSpace#code_around_binding, before colorizingLine numbers are unaffected, since CRLF and LF split into the same lines.
Tests:
TestIRB::SourceFinderTest#test_colorized_content_strips_cr_from_crlf_file(new filetest/irb/test_source_finder.rb)TestIRB::WorkSpaceTest#test_code_around_binding_with_crlf_file