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.
Re-imlement prev_space feature #605 (temporarily dropped in #500)
Code pasted to irb sometimes have base indent. This pull request make IRB indent correctly with base indent
Example of base indent and heredoc
TODO: wait for #515, #608, write tests for heredocdoneBasic algorithm
I defined
base_indentto satisfyactual_indent == base_indent + 2 * indent_level. base_indent can differ on line.Pasted code
Reference code
Line 5 is just inside token
doon line 4. We need to calculate base_indent of line 4 wheredois located.base_indent of line 4 can be calculated by
12 - 2 * indent_level.12 is the indent of pasted code on line 4 and indent_level is 2
Exceptional case
If the beginning of line 4 is inside string literal, we cannot calculate base_indent of line 4.
In that case, base_indent of line 3 is used instead.
Exceptional case 2
Cannot calculate line 4, fallback to line 3 (beginning of tstring_beg)
Cannot calculate line 3, fallback to line 1 (beginning of symbeg)
base_indent of line 1 is 6