Skip to content

Commit a11a0d7

Browse files
authored
* 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.
1 parent 720c893 commit a11a0d7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/vs/workbench/contrib/notebook/browser/view/cellParts/cellComments.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@ import { CellKind } from 'vs/workbench/contrib/notebook/common/notebookCommon';
2020
import { ICellRange } from 'vs/workbench/contrib/notebook/common/notebookRange';
2121

2222
export class CellComments extends CellContentPart {
23-
private readonly _commentThreadWidget = new MutableDisposable<CommentThreadWidget<ICellRange>>;
23+
private readonly _commentThreadWidget: MutableDisposable<CommentThreadWidget<ICellRange>>;
2424
private currentElement: CodeCellViewModel | undefined;
2525
private readonly _commentThreadDisposables = this._register(new DisposableStore());
2626

2727
constructor(
2828
private readonly notebookEditor: INotebookEditorDelegate,
2929
private readonly container: HTMLElement,
30-
3130
@IContextKeyService private readonly contextKeyService: IContextKeyService,
3231
@IThemeService private readonly themeService: IThemeService,
3332
@ICommentService private readonly commentService: ICommentService,
@@ -37,6 +36,8 @@ export class CellComments extends CellContentPart {
3736
super();
3837
this.container.classList.add('review-widget');
3938

39+
this._register(this._commentThreadWidget = new MutableDisposable<CommentThreadWidget<ICellRange>>());
40+
4041
this._register(this.themeService.onDidColorThemeChange(this._applyTheme, this));
4142
// TODO @rebornix onDidChangeLayout (font change)
4243
// this._register(this.notebookEditor.onDidchangeLa)
@@ -108,7 +109,7 @@ export class CellComments extends CellContentPart {
108109
if (this._commentThreadWidget.value) {
109110
if (!info) {
110111
this._commentThreadDisposables.clear();
111-
this._commentThreadWidget.dispose();
112+
this._commentThreadWidget.value = undefined;
112113
this.currentElement.commentHeight = 0;
113114
return;
114115
}
@@ -154,7 +155,6 @@ export class CellComments extends CellContentPart {
154155

155156
override didRenderCell(element: ICellViewModel): void {
156157
if (element.cellKind === CellKind.Code) {
157-
this.currentElement = element as CodeCellViewModel;
158158
this.initialize(element);
159159
this._bindListeners();
160160
}

0 commit comments

Comments
 (0)