Skip to content

mixin_markdown_widget: let MixinSelectionArea settle with MarkdownWidget - #552

Merged
boyan01 merged 1 commit into
mixin_markdown_widget/context-menufrom
mixin_markdown_widget/selection-area-settle
Oct 21, 2026
Merged

boyan01 merged 1 commit into
mixin_markdown_widget/context-menufrom
mixin_markdown_widget/selection-area-settle

Conversation

@boyan01

@boyan01 boyan01 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Summary

MixinSelectionArea + MarkdownWidget never stopped scheduling frames, so pumpAndSettle timed out. Every registrar refresh rebuilt the document view, and the document view always asked for another refresh:

 MixinSelectionArea._refreshDocument
   ++documentVersion, setState
   MixinSelectionRegistrar.updateShouldNotify -> true
     MarkdownWidget (depends on registrar) rebuilds
       MarkdownDocumentView.didUpdateWidget
-        participantChanged(this)              // every time
+        if document is not identical:
+          participantChanged(this)
           _scheduleDocumentRefresh -> next frame -> _refreshDocument ...

The participant's blocks callback reads the current widget.document, so the registrar only needs to rebuild when the document changes. MixinSelectable already notifies only on real changes.

The MixinSelectionArea test in markdown_context_menu_test.dart (#551) worked around this with settle: false. It now uses pumpAndSettle, and the workaround parameter is gone.

Evidence

New test MixinSelectionArea with MarkdownWidget settles:

pump MixinSelectionArea(MarkdownWidget('Hello brave world', useColumn: true))
pumpAndSettle; expect no scheduled frame; selectAll == 'Hello brave world'
change data to 'Hello new world'
pumpAndSettle; expect no scheduled frame; selectAll == 'Hello new world'
  • Before: pumpAndSettle timed out
    After: passes. The second half checks that real document changes still reach the registrar.

flutter test (281 passed) and flutter analyze (no issues) from packages/mixin_markdown_widget.

Merge Danger

Door: two-way

Blast Radius: small

Only MarkdownDocumentView inside a MixinSelectionArea is affected. A host that swaps MarkdownDocumentView arguments other than document (theme, selectable, controller) no longer triggers a registrar refresh by itself; registration and unregistration still go through _syncSelectionParticipant.

MarkdownDocumentView notified its selection registrar on every
didUpdateWidget. Each registrar refresh bumps the document version,
which rebuilds MarkdownWidget and the document view, so the refresh
rescheduled itself every frame and pumpAndSettle never completed.

Notify the registrar only when the rendered document actually changes.
@boyan01
boyan01 added this pull request to stack #545 October 21, 2026 01:47
@boyan01
boyan01 merged commit ad89e54 into main Oct 21, 2026
7 checks passed
@boyan01
boyan01 deleted the mixin_markdown_widget/selection-area-settle branch October 21, 2026 01:49
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.

1 participant