From da5c24a33f81c82019afe2282f359e9cf4968040 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 22 Feb 2022 06:38:01 -0800 Subject: [PATCH] Fix clearMarkers when y=0 and avoid extra indexOf --- src/common/buffer/Buffer.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/common/buffer/Buffer.ts b/src/common/buffer/Buffer.ts index 266c16aa..2841efd8 100644 --- a/src/common/buffer/Buffer.ts +++ b/src/common/buffer/Buffer.ts @@ -587,10 +587,12 @@ export class Buffer implements IBuffer { public clearMarkers(y?: number): void { this._isClearing = true; - if (y) { - for (const marker of this.markers.filter(m => m.line === y)) { - marker.dispose(); - this.markers.splice(this.markers.indexOf(marker), 1); + if (y !== undefined) { + for (let i = 0; i < this.markers.length; i++) { + if (this.markers[i].line === y) { + this.markers[i].dispose(); + this.markers.splice(i, 1); + } } } else { for (const marker of this.markers) {