Skip to content

Commit

Permalink
feat: add isDeadOrDying
Browse files Browse the repository at this point in the history
  • Loading branch information
BeksOmega committed Mar 18, 2024
1 parent e29e2f4 commit 0c1fa59
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/comments/rendered_workspace_comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export class RenderedWorkspaceComment extends WorkspaceComment {

/** Disposes of the view. */
override dispose() {
this.disposing = true;
if (!this.view.isDeadOrDying()) this.view.dispose();
super.dispose();
}
Expand Down
14 changes: 13 additions & 1 deletion core/comments/workspace_comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ export class WorkspaceComment {
private location = new Coordinate(0, 0);

/** Whether this comment has been disposed or not. */
private disposed = false;
protected disposed = false;

/** Whether this comment is being disposed or not. */
protected disposing = true;

/**
* Constructs the comment.
Expand Down Expand Up @@ -158,11 +161,20 @@ export class WorkspaceComment {

/** Disposes of this comment. */
dispose() {
this.disposing = true;
this.disposed = true;
}

/** Returns whether the comment has been disposed or not. */
isDisposed() {
return this.disposed;
}

/**
* Returns true if this comment view is currently being disposed or has
* already been disposed.
*/
isDeadOrDying(): boolean {
return this.disposing || this.disposed;
}
}

0 comments on commit 0c1fa59

Please sign in to comment.