From bbfdcf7dce79d5e82b62b78c37e38bfad41c0c67 Mon Sep 17 00:00:00 2001 From: Joe Stein Date: Thu, 26 Mar 2026 09:23:25 -0700 Subject: [PATCH 1/3] Remove indentation level special-casing in TieredLinesElider --- lib/super_diff/core/tiered_lines_elider.rb | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/super_diff/core/tiered_lines_elider.rb b/lib/super_diff/core/tiered_lines_elider.rb index 1624b3fa..a86d0439 100644 --- a/lib/super_diff/core/tiered_lines_elider.rb +++ b/lib/super_diff/core/tiered_lines_elider.rb @@ -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) @@ -137,8 +139,7 @@ def box_groups_at_decreasing_indentation_levels_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| @@ -167,14 +168,6 @@ 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) combine(boxes, on: :indentation_level) end From 86d90ad5d3c9a91c0985856bfbcc9562c2a8899e Mon Sep 17 00:00:00 2001 From: Joe Stein Date: Thu, 26 Mar 2026 14:42:31 -0700 Subject: [PATCH 2/3] s/congruent/contiguous --- lib/super_diff/core/tiered_lines_elider.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/super_diff/core/tiered_lines_elider.rb b/lib/super_diff/core/tiered_lines_elider.rb index a86d0439..4d4e06a9 100644 --- a/lib/super_diff/core/tiered_lines_elider.rb +++ b/lib/super_diff/core/tiered_lines_elider.rb @@ -131,7 +131,7 @@ 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) @@ -168,7 +168,7 @@ def filter_out_boxes_fully_contained_in_others(boxes) end end - def combine_congruent_boxes(boxes) + def combine_contiguous_boxes(boxes) combine(boxes, on: :indentation_level) end From 5c7b40c3efdbd23f8e8afc5c4eba499049aeda68 Mon Sep 17 00:00:00 2001 From: Joe Stein Date: Thu, 26 Mar 2026 14:52:38 -0700 Subject: [PATCH 3/3] Add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2088fe1b..0fe11aec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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