Skip to content

Commit

Permalink
Merge pull request #4465 from Tyriar/4410
Browse files Browse the repository at this point in the history
Ensure Decoration.isDisposed can be true
  • Loading branch information
Tyriar committed Mar 31, 2023
2 parents c8e633e + c546f7c commit 2fdb469
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
30 changes: 30 additions & 0 deletions src/common/services/DecorationService.test.ts
@@ -0,0 +1,30 @@
/**
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
* @license MIT
*/

import { assert } from 'chai';
import { DecorationService } from './DecorationService';
import { EventEmitter } from 'common/EventEmitter';
import { IMarker } from 'common/Types';
import { Disposable } from 'common/Lifecycle';

const fakeMarker: IMarker = Object.freeze(new class extends Disposable {
public readonly id = 1;
public readonly line = 1;
public readonly isDisposed = false;
public readonly onDispose = new EventEmitter<void>().event;
}());

describe('DecorationService', () => {
it('should set isDisposed to true after dispose', () => {
const service = new DecorationService();
const decoration = service.registerDecoration({
marker: fakeMarker
});
assert.ok(decoration);
assert.isFalse(decoration!.isDisposed);
decoration!.dispose();
assert.isTrue(decoration!.isDisposed);
});
});
2 changes: 1 addition & 1 deletion src/common/services/DecorationService.ts
Expand Up @@ -104,7 +104,7 @@ export class DecorationService extends Disposable implements IDecorationService
class Decoration extends Disposable implements IInternalDecoration {
public readonly marker: IMarker;
public element: HTMLElement | undefined;
public isDisposed: boolean = false;
public get isDisposed(): boolean { return this._isDisposed; }

public readonly onRenderEmitter = this.register(new EventEmitter<HTMLElement>());
public readonly onRender = this.onRenderEmitter.event;
Expand Down

0 comments on commit 2fdb469

Please sign in to comment.