Skip to content

Fixes #5237. Fix Markdown table row height calculation#5238

Merged
tig merged 3 commits intodevelopfrom
copilot/fix-markdown-table-row-calculations
May 7, 2026
Merged

Fixes #5237. Fix Markdown table row height calculation#5238
tig merged 3 commits intodevelopfrom
copilot/fix-markdown-table-row-calculations

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 7, 2026

Fixes

Initial layout of a Markdown view with a large table produces extra blank lines after the table. Resizing the terminal corrects the layout.

Proposed Changes/Todos

  • Fix table height placeholder calculation in BuildRenderedLines

Root Cause

Add(tableView) triggers EndInit()Layout()OnSubViewLayoutRecalculate(Frame.Width) using a stale content width from the previous layout pass. This overwrites RenderedHeight with an incorrect value before it's read for placeholder line reservation.

Fix

Capture RenderedHeight immediately after Recalculate(tableLayoutWidth) and before Add(tableView):

tableView.Recalculate (tableLayoutWidth);

// Capture BEFORE Add() — Add triggers EndInit → Layout → Recalculate at stale width
int tableHeight = tableView.RenderedHeight;

// ... event wiring ...

_tableViews.Add (tableView);
Add (tableView);

for (var i = 0; i < tableHeight; i++)
{
    _renderedLines.Add (...);
}

Previously tableView.RenderedHeight was read after Add(tableView), by which point the value had been corrupted by the initialization cascade.

Pull Request checklist:

  • I've named my PR in the form of "Fixes #issue. Terse description."
  • My code follows the style guidelines of Terminal.Gui - if you use Visual Studio, hit CTRL-K-D to automatically reformat your files before committing.
  • My code follows the Terminal.Gui library design guidelines
  • I ran dotnet test before commit
  • I have made corresponding changes to the API documentation (using /// style comments)
  • My changes generate no new warnings
  • I have checked my code and corrected any poor grammar or misspellings
  • I conducted basic QA to assure all features are working

Copilot AI assigned Copilot and tig May 7, 2026
Copilot AI linked an issue May 7, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits May 7, 2026 14:25
Copilot AI changed the title [WIP] Fix incorrect table row calculations in Markdown Fixes #5765. Fix Markdown table row height calculation May 7, 2026
Copilot finished work on behalf of tig May 7, 2026 14:30
Copilot AI requested a review from tig May 7, 2026 14:30
@tig tig changed the title Fixes #5765. Fix Markdown table row height calculation Fixes #5237. Fix Markdown table row height calculation May 7, 2026
@tig tig marked this pull request as ready for review May 7, 2026 16:47
@tig tig requested a review from BDisp May 7, 2026 16:48
@tig tig merged commit 6ec0175 into develop May 7, 2026
11 checks passed
@tig tig deleted the copilot/fix-markdown-table-row-calculations branch May 7, 2026 18:16
tig added a commit that referenced this pull request May 7, 2026
* Initial plan

* Initial investigation - identified root cause of table height bug

Agent-Logs-Url: https://github.com/gui-cs/Terminal.Gui/sessions/45793f28-879a-4343-aeae-67c066c28785

Co-authored-by: tig <585482+tig@users.noreply.github.com>

* Fix table row height calculation: capture RenderedHeight before Add() triggers EndInit cascade

Agent-Logs-Url: https://github.com/gui-cs/Terminal.Gui/sessions/45793f28-879a-4343-aeae-67c066c28785

Co-authored-by: tig <585482+tig@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: tig <585482+tig@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Markdown - Table row calculations incorrect

3 participants