Clear all decorations on reset

This commit is contained in:
Daniel Imms
2022-05-10 12:32:06 -07:00
parent 6b4df216d3
commit edba006045
4 changed files with 10 additions and 0 deletions
+1
View File
@@ -1358,6 +1358,7 @@ export class Terminal extends CoreTerminal implements ITerminal {
this._setup();
super.reset();
this._selectionService?.reset();
this._decorationService.reset();
// reattach
this._customKeyEventHandler = customKeyEventHandler;
+1
View File
@@ -166,6 +166,7 @@ export class MockDecorationService implements IDecorationService {
public onDecorationRegistered = new EventEmitter<IInternalDecoration>().event;
public onDecorationRemoved = new EventEmitter<IInternalDecoration>().event;
public registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined { return undefined; }
public reset(): void { }
public *getDecorationsOnLine(line: number): IterableIterator<IInternalDecoration> { }
public dispose(): void { }
}
+7
View File
@@ -49,6 +49,13 @@ export class DecorationService extends Disposable implements IDecorationService
return decoration;
}
public reset(): void {
for (let i = 0; i < this._decorations.length; i++) {
this._decorations[0].dispose();
}
this._decorations.length = 0;
}
public *getDecorationsOnLine(line: number): IterableIterator<IInternalDecoration> {
// TODO: This could be made much faster if _decorations was sorted by line (and col?)
for (const d of this.decorations) {
+1
View File
@@ -308,6 +308,7 @@ export interface IDecorationService extends IDisposable {
readonly onDecorationRegistered: IEvent<IInternalDecoration>;
readonly onDecorationRemoved: IEvent<IInternalDecoration>;
registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined;
reset(): void;
/** Iterates over the decorations on a line (in no particular order). */
getDecorationsOnLine(line: number): IterableIterator<IInternalDecoration>;
}