Skip to content

Avoid idle Markdown selection layout work - #1617

Merged
Alexandre Zollinger Chohfi (azchohfi) merged 9 commits into
microsoft:mainfrom
bkudiess:bkudiess-markdown-selection-layout-performance
Nov 23, 2026
Merged

Alexandre Zollinger Chohfi (azchohfi) merged 9 commits into
microsoft:mainfrom
bkudiess:bkudiess-markdown-selection-layout-performance

Conversation

@bkudiess

Copy link
Copy Markdown
Contributor

Summary

Idle Markdown selection scopes no longer do membership, native-text, or geometry work on unrelated window layout passes. Refresh is demand-driven for idle scopes, with continuous tracking retained for active selection, drag, and focused caret; per-owner text transforms are cached during geometry work.

Linked issue / spec

Part of #1475 (Markdown text selection).

Test plan

  • Added Markdown_Selection_IdleLayoutCost selftest, exercising 24 scopes against unrelated layout and streamed content; 104 Markdown selection selftest assertions passed across five fixtures.
  • dotnet test tests/Reactor.Tests --no-build -p:Platform=x64 --filter-class '*MarkdownTextSelectionTests*' — passed (73 tests).
  • dotnet test tests/Reactor.AppTests --no-build -p:Platform=x64 --filter 'ClassName=Microsoft.UI.Reactor.AppTests.Tests.MarkdownSelectionInputProofTests' — passed (real input and UIA event proof).
  • dotnet build src/Reactor.Advanced --no-restore -c Release -p:Platform=x64 -p:SkipSignaturesGen=true -m:1 -nodereuse:false -v:quiet — passed.
  • Full solution restore/build and all test suites were not run.

Risk / breaking changes

No public API or consumer-pattern change; one Scope per message remains supported in ItemsView. Active scopes intentionally retain layout-time native text validation. Idle UIA text-change listeners schedule a coalesced refresh when semantic content changes.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice cut on the idle cost. Main thing is the TextChanged event on idle scopes, plus a couple of tests that call Refresh() directly and so miss the paths this changes.

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.

🟡 Changes recommended

UI Automation text-change notifications can be missed because modifier visibility changes do not invalidate the document and semantic-only updates can leave refreshes pending indefinitely.

2 open issues
What changed in this PR

This PR reduces idle work in Markdown text-selection scopes introduced by #1475, while preserving continuous layout tracking for active selection, dragging, and focused carets.

Changes:

  • Makes idle document refresh demand-driven and caches per-owner geometry transforms.
  • Adds idle-layout regression coverage and strengthens the streaming accessibility-event test.
  • Documents the refresh behavior and continued support for one scope per message.
File Description
tests/​Reactor.AppTests/​Tests/​MarkdownSelectionInputProofTests.cs Checks idle streaming events without triggering a provider refresh.
tests/​Reactor.AppTests.Host/​SelfTest/​SelfTestFixtureRegistry.cs Registers the idle-layout fixture.
tests/​Reactor.AppTests.Host/​SelfTest/​Fixtures/​MarkdownSelectionFixtures.cs Tests idle work, lazy refresh, transform caching, and active tracking.
src/​Reactor.Advanced/​Markdown/​MarkdownTextSelection.cs Narrows semantic invalidation and tracks marker lifecycle changes.
src/​Reactor.Advanced/​Markdown/​MarkdownSelectionHost.cs Adds demand-driven layout subscriptions and transform caching.
docs/​guide/​text-and-media.md Explains idle and active refresh behavior.
docs/​_pipeline/​templates/​text-and-media.md.dt Updates the source template for the guide.
CHANGELOG.md Records the idle-selection performance improvement.

Review effort: Balanced

Semantic-only changes such as a MarkdownTextSelection.Visibility gate do not
invalidate layout, so the LayoutUpdated subscription never fired and UIA
TextChanged listeners waited for unrelated layout work.

Co-authored-by: Copilot App <[email protected]>
…ection-layout-performance

# Conflicts:
#	CHANGELOG.md
…ection-layout-performance

# Conflicts:
#	CHANGELOG.md
@azchohfi
Alexandre Zollinger Chohfi (azchohfi) merged commit 035bc0b into microsoft:main Nov 23, 2026
43 checks passed
Barbara Kudiess (bkudiess) added a commit to bkudiess/microsoft-ui-reactor that referenced this pull request Nov 23, 2026
Integrate main including microsoft#1617 with the existing viewport-boundary and word/paragraph stationary autoscroll regressions. Preserve shared drag selection updates and message-clipped press acceptance.

Co-authored-by: Copilot App <[email protected]>
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.

3 participants