Remove indentation level special-casing in TieredLinesElider#307
Merged
Conversation
a14d172 to
bbfdcf7
Compare
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.
As promised. Two minor changes:
First, in
#all_indentation_levels, we were excluding bookends by inference: specifically, we assumed that if there were nonzero indentation levels, the lines with indentation level zero must be top-level bookends. We can just ask if&:complete_bookend?instead.Second – and this one is more complicated – it turns out we don't need to exclude level 0 from
box_groups_at_decreasing_indentation_levels_within(pane). Why?First, note that only clean panes are ever elided. Furthermore, we can assume that there is at least one dirty pane; otherwise, we don't try to elide.
Now: for a top-level structure (no nesting), such as a multi-line string, we want to include level-0 boxes for elision. For nested structures, we don't, because we don't want to elide the bookend symbols/lines, such as
{/}for a Hash[/]for an Array, etc.However, a level-0 box for a nested structure necessarily spans the entire structure and therefore all lines; it starts with the open bookend and ends with the close bookend. And since there is at least one dirty pane, it's not possible for that level-0 box to fit within any given pane. Thus, level-0 boxes for nested structured will be filtered out of
boxes_within_pane.So, for nested structures,
possible_indentation_levelswill still exclude 0. For flat top-level structures, a top-level box would have been created for each top-level line, so it should still include zero.