Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix leaking comment thread when CellComment is reused. #214589

Merged
merged 5 commits into from
Jun 24, 2024

Conversation

rehmsen
Copy link
Contributor

@rehmsen rehmsen commented Jun 7, 2024

Fixes #214585.

As none of the involved classes are covered by unit tests, to test this one needs to create a notebook with a code cell, then a page long markup cell, then a code cell, so that the two code cells are not visible at the same time, and the renderer reuses the same CellComments for them as you scroll up and down. Then you need to put a notebook comment onto the first cell. Before this change, that comment also is shown incorrectly on the second code cell when scrolling down as it is not correctly cleaned up. with this change, this does not happen, the CommentThreadWidget and associated DOM elements are removed, and then added back again cleanly when scrolling back up to the first code cell.

Copy link
Contributor Author

@rehmsen rehmsen left a comment

Choose a reason for hiding this comment

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

Remove accidental change in test/automation/package.json.

rebornix
rebornix previously approved these changes Jun 7, 2024
Copy link
Member

@rebornix rebornix left a comment

Choose a reason for hiding this comment

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

Thanks!

@rebornix rebornix requested a review from alexr00 June 7, 2024 18:55
@vscodenpa vscodenpa added this to the June 2024 milestone Jun 7, 2024
@rehmsen
Copy link
Contributor Author

rehmsen commented Jun 17, 2024

Hi @alexr00, did you have a chance to look at this? Do you have any questions? It would be cool to get this fix in. Thanks!

Copy link
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

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

I just have one question:

@rehmsen rehmsen dismissed stale reviews from Tyriar and rebornix via 825680c June 17, 2024 15:05
Copy link
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

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

Other than the change to test/automation/package.json I'm happy with the change!

test/automation/package.json Outdated Show resolved Hide resolved
I wonder if VSCode or some extension I have keeps updating this? I am not doing it handishly. Anyways, gone again.
@alexr00 alexr00 requested a review from rebornix June 18, 2024 09:19
Copy link
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

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

Looks good, thank you! I'll just let @rebornix re-review.

@rehmsen
Copy link
Contributor Author

rehmsen commented Jun 20, 2024

@rebornix Are you still happy with the changes I made in response to other reviewers' comments? Can this change be merged?

Copy link
Member

@rebornix rebornix left a comment

Choose a reason for hiding this comment

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

Looks great!

@rebornix rebornix merged commit a5fea0c into microsoft:main Jun 24, 2024
6 checks passed
@rebornix
Copy link
Member

@rehmsen sorry for the late response, the code looks great! Thank you for the contribution ❤️

bricefriha pushed a commit to bricefriha/vscode that referenced this pull request Jun 26, 2024
…ecycle

Fix leaking comment thread when CellComment is reused.
rehmsen added a commit to rehmsen/vscode that referenced this pull request Jun 26, 2024
1. We must not `dispose()` the `MutableDisposable` `this._commentThreadWidget` - as that disposes the MutableDisposable itself, and it cannot then later be reassigned to a new value. Instead, we need to assign `value=undefined`, which disposes the previous `value`, but keeps the `MutableDisposable` available to be reused later.
2. `initialize()` is a no-op if `this.currentElement` is already identical to the passed `element`, so we must not do that assignment before calling initialize - instead `initialize()` does the assignment after checking.
alexr00 pushed a commit that referenced this pull request Jun 26, 2024
* Fix two bugs in #214589.

1. We must not `dispose()` the `MutableDisposable` `this._commentThreadWidget` - as that disposes the MutableDisposable itself, and it cannot then later be reassigned to a new value. Instead, we need to assign `value=undefined`, which disposes the previous `value`, but keeps the `MutableDisposable` available to be reused later.
2. `initialize()` is a no-op if `this.currentElement` is already identical to the passed `element`, so we must not do that assignment before calling initialize - instead `initialize()` does the assignment after checking.

* Fix blank line.

* Register the _commentThreadWidget MutableDisposable so that it gets disposed when CellComments is disposed.
aaronchucarroll pushed a commit to aaronchucarroll/vscode that referenced this pull request Jul 10, 2024
…ecycle

Fix leaking comment thread when CellComment is reused.
aaronchucarroll pushed a commit to aaronchucarroll/vscode that referenced this pull request Jul 10, 2024
…218357)

* Fix two bugs in microsoft#214589.

1. We must not `dispose()` the `MutableDisposable` `this._commentThreadWidget` - as that disposes the MutableDisposable itself, and it cannot then later be reassigned to a new value. Instead, we need to assign `value=undefined`, which disposes the previous `value`, but keeps the `MutableDisposable` available to be reused later.
2. `initialize()` is a no-op if `this.currentElement` is already identical to the passed `element`, so we must not do that assignment before calling initialize - instead `initialize()` does the assignment after checking.

* Fix blank line.

* Register the _commentThreadWidget MutableDisposable so that it gets disposed when CellComments is disposed.
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Aug 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants