Skip to content

Fixes #5639. Harden TextView text synchronization - #5645

Merged
YourRobotOverlord merged 3 commits into
tui-cs:developfrom
YourRobotOverlord:fix/5639-textview-setter-guard
Aug 27, 2026
Merged

Fixes #5639. Harden TextView text synchronization#5645
YourRobotOverlord merged 3 commits into
tui-cs:developfrom
YourRobotOverlord:fix/5639-textview-setter-guard

Conversation

@YourRobotOverlord

Copy link
Copy Markdown
Collaborator

Summary

Hardens TextView.Text synchronization when post-change notification throws or performs a reentrant polymorphic assignment.

Changes

  • Finalize draw and history state before raising TextChanged.
  • Reset the synchronization guard in finally after subscriber failures.
  • Consume the guard before subscriber dispatch so reentrant View.Text assignments update the internal model.
  • Add regression tests for exception recovery, history consistency, and reentrant polymorphic synchronization.

Testing

  • dotnet build --configuration Debug --no-restore — passed with 0 errors and 3 pre-existing XML documentation warnings.
  • Text CWP tests — 27 passed.
  • TextView tests — 430 passed, 4 skipped.
  • Non-parallel tests — 72 passed, 2 skipped.
  • Full parallel suite — 17,585 passed, 17 skipped, and 4 unrelated ANSI color-encoding expectation failures in SchemeColorNoneDerivationTests and ViewDrawingClippingTests.

To pull down this PR locally:

git remote add copilot https://github.com/YourRobotOverlord/Terminal.Gui.git
git fetch copilot fix/5639-textview-setter-guard
git checkout copilot/fix/5639-textview-setter-guard

Finalize history and drawing state before TextChanged and always clear the setter guard after subscriber failures.\n\nRefs tui-cs#5639
Consume the one-shot synchronization guard before TextChanged subscribers run so nested View.Text assignments reach the model.\n\nRefs tui-cs#5639

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

Hardens TextView.Text synchronization and recovery by ensuring internal state updates complete before TextChanged dispatch, and by making the synchronization guard resilient to exceptions and reentrant polymorphic View.Text assignments (fixing #5639).

Changes:

  • Reworks TextView.Text setter / OnTextChanged guard logic to clear the guard via finally and allow reentrant polymorphic sets to resync the internal model.
  • Finalizes draw + history baseline state before raising TextChanged so exceptions don’t leave TextView inconsistent.
  • Adds regression tests covering throwing TextChanged subscribers, history baseline consistency, and reentrant polymorphic synchronization.

Reviewed changes

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

File Description
Terminal.Gui/Views/TextInput/TextView/TextView.Text.cs Makes TextView text sync guard exception-safe and reentrancy-safe while preserving CWP behavior.
Tests/UnitTestsParallelizable/ViewBase/TextCwpTests.cs Adds regression coverage for exception recovery, history baseline consistency, and reentrant polymorphic syncing.
Suppressed comments (2)

Tests/UnitTestsParallelizable/ViewBase/TextCwpTests.cs:195

  • AI-generated test marker comment does not follow the required repository format. .claude/rules/testing-patterns.md specifies the marker must be either // Claude - <model> or // CoPilot - <model> (both accepted).
    // Codex - GPT-5.6

Tests/UnitTestsParallelizable/ViewBase/TextCwpTests.cs:208

  • AI-generated test marker comment does not follow the required repository format. .claude/rules/testing-patterns.md specifies the marker must be either // Claude - <model> or // CoPilot - <model> (both accepted).
    // Codex - GPT-5.6

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Tests/UnitTestsParallelizable/ViewBase/TextCwpTests.cs Outdated
Comment thread Tests/UnitTestsParallelizable/ViewBase/TextCwpTests.cs
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@YourRobotOverlord
YourRobotOverlord merged commit 48efa0c into tui-cs:develop Aug 27, 2026
14 checks passed
@YourRobotOverlord
YourRobotOverlord deleted the fix/5639-textview-setter-guard branch August 27, 2026 17:31
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.

TextView new-Text setter: guard flag not cleared in finally — throwing TextChanged subscriber permanently breaks polymorphic Text sync

3 participants