dispose of ref instead of object itself to avoid null objects.#266299
Merged
mjbvz merged 1 commit intomicrosoft:mainfrom Sep 29, 2025
Merged
dispose of ref instead of object itself to avoid null objects.#266299mjbvz merged 1 commit intomicrosoft:mainfrom
mjbvz merged 1 commit intomicrosoft:mainfrom
Conversation
saky-semicolon
left a comment
There was a problem hiding this comment.
Yeah we can drop the first call (ref.object.dispose()) and keep ref.dispose() as the correct disposal.
Contributor
Author
|
I did notice there was a recent pr for the telemetry issues here. I could remove the check and or comment if desired, or leave it; whichever is desired there. #260445 |
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
0da28cf to
4aa9b2e
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a critical bug in Copilot chat where code blocks would shrink to 0 height and become invisible when scrolling through chats with many code blocks (100+). The issue was caused by improper disposal of text model references in the CodeBlockModelCollection class.
Key changes:
- Fixed disposal logic to dispose references instead of the underlying models
- Corrected both
delete()andclear()methods inCodeBlockModelCollection - Ensures models remain valid during virtualization cycles
mjbvz
approved these changes
Sep 29, 2025
chrmarti
approved these changes
Sep 29, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes an issue with scrolling in Copilot chats with many code blocks (100+). The behavior is that after scrolling up and down through the chat, some code blocks shrink to 0 height and the code is no longer visible. See the included video for an example:
Screen.Recording.2025-09-11.at.5.21.20.PM.mov
Root Cause
The problem came from how
CodeBlockModelCollectionwas disposing models. It was callingref.object.dispose(), which disposes the underlying text model itself. Instead, it should callref.dispose(), which disposes the reference and releases it.By disposing the model directly, later code block components ended up with null/invalid models during virtualization cycles. That’s why editors collapsed or reported
content height = -1.Fix
Replace calls to
ref.object.dispose()withref.dispose()indelete()andclear(). This properly disposes the reference, allowing models to remain valid and be reused when scrolling back.Testing
./scripts/test.sh) with no regressions.Screen.Recording.2025-09-11.at.5.16.12.PM.mov
Related
Fixes #266296
Related telemetry issues: #240028, #248829, #255827