Skip to content

Fixes #5555. Preserve explicit Scheme role reassignment#5556

Merged
YourRobotOverlord merged 1 commit into
tui-cs:developfrom
YourRobotOverlord:codex/fix-scheme-explicit-role-reassignment
Jun 28, 2026
Merged

Fixes #5555. Preserve explicit Scheme role reassignment#5556
YourRobotOverlord merged 1 commit into
tui-cs:developfrom
YourRobotOverlord:codex/fix-scheme-explicit-role-reassignment

Conversation

@YourRobotOverlord

Copy link
Copy Markdown
Collaborator

Description

Preserves an explicitly assigned Scheme role when a copied scheme
reassigns that role to the same Attribute.

Previously, SetAttributeForRoleProperty compared the assignment with the
resolved role value and converted a matching value to null. For copied
schemes, this erased the copied explicit value and caused the role to be
derived from Normal.

Tests

Added a regression test covering an identical Editable reassignment after
copying and changing Normal.

  • Full parallelizable suite: 17,453 passed, 17 skipped
  • Scheme tests: 46 passed
  • git diff --check: passed

To pull down this PR locally:

git remote add copilot https://github.com/YourRobotOverlord/Terminal.Gui.git
git fetch copilot codex/fix-scheme-explicit-role-reassignment
git checkout copilot/codex/fix-scheme-explicit-role-reassignment

Reassigning a copied explicit role to the same value must not make it implicit.

Fixes tui-cs#5555
@YourRobotOverlord YourRobotOverlord marked this pull request as ready for review June 28, 2026 04:39
@YourRobotOverlord YourRobotOverlord requested a review from tig as a code owner June 28, 2026 04:39
@tig tig requested a review from Copilot June 28, 2026 15:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a Scheme copy/initializer edge case where reassigning an explicitly set role to the same Attribute value could incorrectly clear the explicit backing field and cause the role to be re-derived from Normal.

Changes:

  • Update Scheme.SetAttributeForRoleProperty to keep an already-explicit role explicit when reassigned the same value.
  • Add a regression test covering explicit Editable preservation after copying and changing Normal.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Terminal.Gui/Drawing/Scheme.cs Preserves explicit role assignments when reassigned to the same value during initialization/copy scenarios.
Tests/UnitTestsParallelizable/Drawing/SchemeTests.cs Adds regression coverage validating explicit Editable remains explicit after copy + reassignment.

Comment thread Tests/UnitTestsParallelizable/Drawing/SchemeTests.cs

@tig tig left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Good catch.

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.

Copying a Scheme and reassigning an identical role removes its explicit value

3 participants