Skip to content

Commit e8bd8e4

Browse files
committed
🔧 [Text] Improve alg for horiz lines at column labels
1 parent 62c9c70 commit e8bd8e4

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

src/backends/text/display.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,11 @@ function _text__print_column_label_horizontal_line(
358358
# We must compute if the cell at the top or at the bottom from the current
359359
# horizontal line is merged. Notice that if we are at the top of the table, the
360360
# effect is equal to have a merged cell above it.
361-
tcm = _is_column_label_cell_merged(table_data, row_number, j + 1) || top
362-
bcm = _is_column_label_cell_merged(table_data, row_number + 1, j + 1)
361+
top_j₀, top_j₁ = _column_label_limits(table_data, row_number, j + 1)
362+
bottom_j₀, bottom_j₁ = _column_label_limits(table_data, row_number + 1, j + 1)
363+
364+
tcm = (top_j₀ != top_j₁) && (j + 1 != top_j₀ ) || top
365+
bcm = (bottom_j₀ != bottom_j₁) && (j + 1 != bottom_j₀)
363366

364367
if tf.suppress_vertical_lines_at_column_labels
365368
bcm = tcm = true

src/printing_state/information.jl

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,11 @@ end
7575
"""
7676
_is_column_label_cell_merged(table_data::TableData, i::Int, j::Int) -> Bool
7777
78-
Return whether the cell at `(i, j)` is a merged column label cell. Notice that this function
79-
returns `true` only if `(i, j)` is in the middle of the merged cell. If the merged cell
80-
starts at `(i, j)`, this function returns `false`.
78+
Return whether the cell at `(i, j)` is a merged column label cell.
8179
"""
8280
function _is_column_label_cell_merged(table_data::TableData, i::Int, j::Int)
83-
isnothing(table_data.merge_column_label_cells) && return false
84-
85-
# Check if this cell must be merged or if is is part of a merged cell.
86-
for mc in table_data.merge_column_label_cells
87-
if mc.i == i && (mc.j < j <= mc.j + mc.column_span - 1)
88-
return true
89-
end
90-
end
91-
92-
return false
81+
j₀, j₁ = _column_label_limits(table_data, i, j)
82+
return j₀ != j₁
9383
end
9484

9585
"""

0 commit comments

Comments
 (0)