Remove needless removal of trailing whitespace in check_code_state #678
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.
IRB unnecessarily removes trailing white space before checking
should_continue?
. It results in failure of executing tricky syntax.Reason why there was gsub and why it's not needed now
The old implementation of
should_continue?
(process_continue
) was assumingtokens[-1]
is newline andtokens[-2]
is the last non-whitespace token.code.gsub(/\s*\z/, '').concat("\n")
was ensuring that assumption.https://github.com/ruby/irb/pull/611/files#diff-612b926e42ed78aed1a889ac1944f7d22229b3a489cc08f837a7f75eca3d3399L250-L262
The implementation is changed to skip continuous trailing newline, space, and comment-like tokens so we don't need that gsub anymore.