Skip to content

Clear scroll marks when clearing the buffer#20105

Open
SushaanthSrinivasan wants to merge 2 commits intomicrosoft:mainfrom
SushaanthSrinivasan:fix/clear-buffer-scroll-marks
Open

Clear scroll marks when clearing the buffer#20105
SushaanthSrinivasan wants to merge 2 commits intomicrosoft:mainfrom
SushaanthSrinivasan:fix/clear-buffer-scroll-marks

Conversation

@SushaanthSrinivasan
Copy link
Copy Markdown

@SushaanthSrinivasan SushaanthSrinivasan commented Apr 11, 2026

Summary

Fixes #20086 — Ctrl+Shift+K (Clear Buffer) now clears scroll marks from the scrollbar.

References and Relevant Issues

Detailed Description

ControlCore::ClearBuffer() sends VT escape sequences to clear the buffer. The scrollback path (\x1b[3J) already clears marks via TextBuffer::ClearScrollback, but the screen-clearing path doesn't touch marks — they persist stale in the scrollbar.

This adds a ClearAllMarks() call inside the existing lock block after the VT sequences are written, for both Screen and All clear types.

Validation Steps

  1. Enable "showMarksOnScrollbar": true in profile defaults
  2. Open a PowerShell tab, hit Enter ~20 times to generate scroll marks
  3. Press Ctrl+Shift+K — marks should disappear
  4. Hit Enter again — new marks should appear normally
before.after.mp4

Copy link
Copy Markdown
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am surprised that the Erase in Screen handler does not already do this.

It seems to me that fixing the issue in this layer will not fix the case in issue #20086 with the clear command, because the clear command does not run through this code.

We should fix this in the appropriate layer if possible.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Apr 13, 2026
Copy link
Copy Markdown
Author

@SushaanthSrinivasan SushaanthSrinivasan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added ClearMarksInRange to _EraseAll() in adaptDispatch.cpp — fixes clear/cls which go through the \x1b[2J path.

ctrl+shift+k still needs the ControlCore fix though — ClearBuffer() uses DL + ED0 to preserve the cursor row (GH#18732), so it never hits _EraseAll.

pushed both fixes, tested all three paths (ctrl+shift+k, bash clear, powershell cls). dropping the screen rec below:

wt.scroll.clear.mp4

@microsoft-github-policy-service microsoft-github-policy-service Bot removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Apr 15, 2026
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.

Clear buffer doesn't clear scroll marks

2 participants