mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Be more defensive around SortedList key
Fixes #3885 Part of microsoft/vscode#151225
This commit is contained in:
@@ -34,6 +34,9 @@ export class SortedList<T> {
|
||||
return false;
|
||||
}
|
||||
const key = this._getKey(value);
|
||||
if (key === undefined) {
|
||||
return false;
|
||||
}
|
||||
let i = this._search(key, 0, this._array.length - 1);
|
||||
if (i === -1) {
|
||||
return false;
|
||||
@@ -75,10 +78,11 @@ export class SortedList<T> {
|
||||
return min;
|
||||
}
|
||||
let mid = Math.floor((min + max) / 2);
|
||||
if (this._getKey(this._array[mid]) > key) {
|
||||
const midKey = this._getKey(this._array[mid]);
|
||||
if (midKey > key) {
|
||||
return this._search(key, min, mid - 1);
|
||||
}
|
||||
if (this._getKey(this._array[mid]) < key) {
|
||||
if (midKey < key) {
|
||||
return this._search(key, mid + 1, max);
|
||||
}
|
||||
// Value found! Since keys can be duplicates, move the result index back to the lowest index
|
||||
|
||||
@@ -19,7 +19,7 @@ export class DecorationService extends Disposable implements IDecorationService
|
||||
* while marker line values do change, they should all change by the same amount so this should
|
||||
* never become out of order.
|
||||
*/
|
||||
private readonly _decorations: SortedList<IInternalDecoration> = new SortedList(e => e.marker.line);
|
||||
private readonly _decorations: SortedList<IInternalDecoration> = new SortedList(e => e?.marker.line);
|
||||
|
||||
private _onDecorationRegistered = this.register(new EventEmitter<IInternalDecoration>());
|
||||
public get onDecorationRegistered(): IEvent<IInternalDecoration> { return this._onDecorationRegistered.event; }
|
||||
@@ -28,10 +28,6 @@ export class DecorationService extends Disposable implements IDecorationService
|
||||
|
||||
public get decorations(): IterableIterator<IInternalDecoration> { return this._decorations.values(); }
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
public registerDecoration(options: IDecorationOptions): IDecoration | undefined {
|
||||
if (options.marker.isDisposed) {
|
||||
return undefined;
|
||||
|
||||
Reference in New Issue
Block a user