Skip to content

fix(mdstream): clamp stable line count to prevent dropping lines shorter than live window - #5659

Open
lx3133584 wants to merge 1 commit into
Aider-AI:mainfrom
lx3133584:fix/mdstream-short-live-window
Open

fix(mdstream): clamp stable line count to prevent dropping lines shorter than live window#5659
lx3133584 wants to merge 1 commit into
Aider-AI:mainfrom
lx3133584:fix/mdstream-short-live-window

Conversation

@lx3133584

Copy link
Copy Markdown

Problem

When the rendered output is shorter than live_window, MarkdownStream.update computes a negative num_lines (len(lines) - self.live_window), which causes Python slice lines[num_lines:] to drop leading rendered lines from the Rich live display instead of displaying all lines.

Root Cause

In aider/mdstream.py, num_lines -= self.live_window yields a negative index when len(lines) < self.live_window. Slicing with a negative index takes only the suffix rather than treating the stable line count as 0.

Fix

Clamp num_lines to 0 with max(0, num_lines - self.live_window).

Testing

Added unit tests in tests/basic/test_mdstream.py covering short window preservation and stable line emission, verified with pytest.

…ter than live window

Fixes Aider-AI#5654

Signed-off-by: Liang Xu <lx3133584@users.noreply.github.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

2 participants