indent deeply-nested EQ_FORMALS correctly #546
Merged
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.
Problem
non-technical: When nested deeper than 1 level, indention of function headers is generally not correct:
Created on 2019-09-23 by the reprex package (v0.3.0)
technical source: In
apply_ref_indention_one()
, the parse table is already flat, the indention of all tokens is absolute. However, for those where indention should be copied from another token, their indention must be relative, otherwise we'll double account for some indention.See this exceprt from
R/reindent.R
,apply_ref_indention_one()
:Formals need to be aligned with the absolute indention of the opening brace. If you add another time their absolute indention, they will be indented way to much.
Solution
When flattening the parse table, keep the indention level of all tokens that have a ref_pos_id relative, so when added with an absolute indention in
apply_ref_indention()
, it will become absolute indention. Closes #541.