[PR #5792] [MERGED] Initialize the text buffer with the default attributes on a resize #26466

Open
opened 2026-01-31 09:16:16 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/5792
Author: @zadjii-msft
Created: 5/7/2020
Status: Merged
Merged: 4/21/2021
Merged by: @undefined

Base: mainHead: dev/migrie/b/3848-resize-color-explosion


📝 Commits (9)

  • 0177498 clean this test up substantially
  • ee92c26 I believe this is the fix for this bug
  • 72e0a55 This should really be in the previous commit as well.
  • f32d1e8 This is another test case for checking the Terminal buffer contents are initialized correctly
  • 1d067cc Make sure to stash the current attributes before the resize, and restore after the resize
  • e945fb3 I believe this is needed here as well.
  • ea66461 Some test cleanup for review
  • 46d6d68 This test passes without any resizing involved
  • c3f9d36 update for merge with main

📊 Changes

3 files changed (+169 additions, -3 deletions)

View changed files

📝 src/cascadia/TerminalCore/Terminal.cpp (+10 -1)
📝 src/cascadia/UnitTests_TerminalCore/ConptyRoundtripTests.cpp (+150 -1)
📝 src/host/screenInfo.cpp (+9 -1)

📄 Description

When we resize the text buffer, initialize the buffer with the
_default_¹ attributes, not the current ones. If we use the current
attributes, then we can get into scenarios where something like vim is
running, and left the attributes set to something other than the
defaults, and when we resized the buffer, we'd fill it up with color, as
opposed to whatever the default would be.

This PR instead initializes the buffers with the default colors. It also
makes sure to set the active attributes of the newly created buffers
back to whatever the current attributes of the old buffer were.

[1]: For the Terminal, the default attributes are "default on default".
For conhost, the default attributes are whatever the result of
Settings::GetDefaultAttributes is, which could be any combo of the
legacy indices and the default color.

PR Checklist

Validation Steps Performed

  • ran tests

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/5792 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 5/7/2020 **Status:** ✅ Merged **Merged:** 4/21/2021 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `dev/migrie/b/3848-resize-color-explosion` --- ### 📝 Commits (9) - [`0177498`](https://github.com/microsoft/terminal/commit/01774989cc9550f5909421f3ffc21a563d9471d8) clean this test up substantially - [`ee92c26`](https://github.com/microsoft/terminal/commit/ee92c26859de58ccec9f51b64c1bdff46a96157c) I believe this is the fix for this bug - [`72e0a55`](https://github.com/microsoft/terminal/commit/72e0a5552cb30dbd21f7240729dbe95a2ca3fdbe) This should really be in the previous commit as well. - [`f32d1e8`](https://github.com/microsoft/terminal/commit/f32d1e853417e7e4c6276f781e684daa0843bd00) This is another test case for checking the Terminal buffer contents are initialized correctly - [`1d067cc`](https://github.com/microsoft/terminal/commit/1d067cc35fd6f20d5033477753c42aef5741d58e) Make sure to stash the current attributes before the resize, and restore after the resize - [`e945fb3`](https://github.com/microsoft/terminal/commit/e945fb30b71f8d35fa1f3d0b00658897c13b8296) I believe this is needed here as well. - [`ea66461`](https://github.com/microsoft/terminal/commit/ea66461a674a660d35cd8f0321a58e3ffdb1913c) Some test cleanup for review - [`46d6d68`](https://github.com/microsoft/terminal/commit/46d6d688b1a693446c37dd2c6dd193f513942d88) This test passes without any resizing involved - [`c3f9d36`](https://github.com/microsoft/terminal/commit/c3f9d36b1b87728b030d1936ad774ee5ffaf7561) update for merge with main ### 📊 Changes **3 files changed** (+169 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalCore/Terminal.cpp` (+10 -1) 📝 `src/cascadia/UnitTests_TerminalCore/ConptyRoundtripTests.cpp` (+150 -1) 📝 `src/host/screenInfo.cpp` (+9 -1) </details> ### 📄 Description When we resize the text buffer, initialize the buffer with the _default_¹ attributes, not the _current_ ones. If we use the current attributes, then we can get into scenarios where something like `vim` is running, and left the attributes set to something other than the defaults, and when we resized the buffer, we'd fill it up with color, as opposed to whatever the default would be. This PR instead initializes the buffers with the default colors. It also makes sure to set the active attributes of the newly created buffers back to whatever the current attributes of the old buffer were. [1]: For the Terminal, the default attributes are "default on default". For conhost, the default attributes are whatever the result of `Settings::GetDefaultAttributes` is, which could be any combo of the legacy indices and the default color. ## PR Checklist * [x] Closes #3848 * [x] I work here * [x] Tests added/passed * [n/a] Requires documentation to be updated ## Validation Steps Performed * ran tests --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:16:16 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#26466