Private
Public Access
0
0

fix(markdown): add missing table_setup_column calls in render_table

ROOT CAUSE: src/markdown_table.py:render_table was missing
imgui.table_setup_column() calls. In ImGui, columns MUST be
configured via table_setup_column before table_headers_row is called.
Without it, the table has no defined columns, causing cells to
render at overlapping Y positions. This manifested as text overlap
in the Discussion Hub's read_mode entries (e.g., 'swc2 -> gte_sw'
overlapping the line above it).

FIX: Call imgui.table_setup_column(h, TableColumnFlags_.width_stretch)
for each header BEFORE table_headers_row(). Each column now has a
defined width (stretch = fills available space) and cells render
correctly without overlap.

Tests:
- New test_markdown_table_columns.py asserts setup_column is called
  once per column and table_next_column is called for each cell.
- 16/16 broad regression pass (test_markdown_table,
  test_markdown_table_render, test_markdown_render_robust,
  test_gen_send_empty_context, test_gui_fast_render)
This commit is contained in:
2026-06-03 15:27:29 -04:00
parent 801321c125
commit afa2f31e11
2 changed files with 14 additions and 0 deletions
+2
View File
@@ -12,6 +12,8 @@ def render_table(block: "TableBlock") -> None:
if n_cols == 0: return
flags = imgui.TableFlags_.borders | imgui.TableFlags_.row_bg | imgui.TableFlags_.resizable
if not imgui.begin_table("md_table", n_cols, flags): return
for h in block.headers:
imgui.table_setup_column(h, imgui.TableColumnFlags_.width_stretch)
imgui.table_headers_row()
for h in block.headers:
imgui.table_next_column()
+12
View File
@@ -0,0 +1,12 @@
from unittest.mock import patch
from src.markdown_table import parse_tables, render_table, TableBlock
def test_render_table_sets_up_columns_before_rows():
block = TableBlock(headers=["A", "B", "C"], rows=[["1", "2", "3"], ["4", "5", "6"]], span=(0, 4))
with patch("src.markdown_table.imgui") as mock_imgui:
mock_imgui.TableFlags_ = type("T", (), {"borders": 1, "row_bg": 2, "resizable": 4})()
mock_imgui.TableColumnFlags_ = type("C", (), {"width_stretch": 1, "width_fixed": 2})()
mock_imgui.begin_table.return_value = True
render_table(block)
assert mock_imgui.table_setup_column.call_count == 3, f"expected 3 table_setup_column calls (one per column), got {mock_imgui.table_setup_column.call_count}"
assert mock_imgui.table_next_column.call_count >= 9, f"expected at least 9 table_next_column calls (3 headers + 6 cells), got {mock_imgui.table_next_column.call_count}"