Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Fix integration snippet indentation. [#299](https://github.com/splitwise/super_diff/pull/299) by [@gschlager](https://github.com/gschlager)
- Pin all actions to full commit SHA. [#305](https://github.com/splitwise/super_diff/pull/305)
- Do not attempt to sub-diff multiline strings. [#304](https://github.com/splitwise/super_diff/pull/304)
- Tweak TieredLinesElider. [#307](https://github.com/splitwise/super_diff/pull/307)

## 0.18.0 - 2025-12-05

Expand Down
21 changes: 7 additions & 14 deletions lib/super_diff/core/tiered_lines_elider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ def one_dimensional_line_tree?
end

def all_indentation_levels
levels = lines.map(&:indentation_level).uniq
normalized_indentation_levels(levels)
lines
.reject(&:complete_bookend?)
.map(&:indentation_level)
.uniq
end

def find_boxes_to_elide_within(pane)
Expand Down Expand Up @@ -129,16 +131,15 @@ def find_boxes_to_elide_within(pane)
def normalized_box_groups_at_decreasing_indentation_levels_within(pane)
box_groups_at_decreasing_indentation_levels_within(pane).map(
&method(:filter_out_boxes_fully_contained_in_others)
).map(&method(:combine_congruent_boxes))
).map(&method(:combine_contiguous_boxes))
end

def box_groups_at_decreasing_indentation_levels_within(pane)
boxes_within_pane = boxes.select { |box| box.fits_fully_within?(pane) }

levels = boxes_within_pane.map(&:indentation_level).uniq

possible_indentation_levels =
normalized_indentation_levels(levels).sort.reverse
possible_indentation_levels = levels.sort.reverse

possible_indentation_levels.map do |indentation_level|
boxes_within_pane.select do |box|
Expand Down Expand Up @@ -167,15 +168,7 @@ def filter_out_boxes_fully_contained_in_others(boxes)
end
end

def normalized_indentation_levels(levels)
# For flat structures (strings), include level 0
return levels if levels.all?(&:zero?)

# For nested structures (arrays, hashes), exclude level 0 (brackets)
levels.select(&:positive?)
end

def combine_congruent_boxes(boxes)
def combine_contiguous_boxes(boxes)
combine(boxes, on: :indentation_level)
end

Expand Down
Loading