Skip to content

Commit

Permalink
Revert "SelectBox: Add bounds checking on selected option. Addresses: #…
Browse files Browse the repository at this point in the history
…43475, #44309 (#47044)"

This reverts commit 043538e.
  • Loading branch information
bpasero committed Apr 6, 2018
1 parent 356c4ba commit 95101bf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 28 deletions.
18 changes: 1 addition & 17 deletions src/vs/base/browser/ui/selectBox/selectBoxCustom.ts
Expand Up @@ -229,17 +229,7 @@ export class SelectBoxList implements ISelectBoxDelegate, IDelegate<ISelectOptio
}

if (selected !== undefined) {
// Guard against out of bounds selected values
// Cannot currently return error, set selected within range
if (selected >= 0 && selected < this.options.length) {
this.select(selected);
} else if (selected > this.options.length - 1) {
// This could make client out of sync with the select
this.select(this.options.length - 1);
console.error('selectBoxCustom: setOptions selected exceeds options length');
} else if (selected < 0) {
this.selected = 0;
}
this.select(selected);
}
}

Expand Down Expand Up @@ -363,12 +353,6 @@ export class SelectBoxList implements ISelectBoxDelegate, IDelegate<ISelectOptio
return;
}

// Bounds check selected/list before attempting to show
if (this.selected < 0 || this.selected > this.options.length - 1 || !this.selectList.length) {
console.error('selectBoxCustom: showSelectDropDown this.select exceeds options length or empty list');
return;
}

this._isVisible = true;
this.cloneElementFont(this.selectElement, this.selectDropDownContainer);
this.contextViewProvider.showContextView({
Expand Down
12 changes: 1 addition & 11 deletions src/vs/base/browser/ui/selectBox/selectBoxNative.ts
Expand Up @@ -84,17 +84,7 @@ export class SelectBoxNative implements ISelectBoxDelegate {
}

if (selected !== undefined) {
// Guard against out of bounds selected values
// Cannot currently return error, set selected within range
if (selected >= 0 && selected < this.options.length) {
this.select(selected);
} else if (selected > this.options.length - 1) {
// This could make client out of sync with the select
this.select(this.options.length - 1);
console.error('selectBoxNative: setOptions selected exceeds options length');
} else if (selected < 0) {
this.selected = 0;
}
this.select(selected);
}
}

Expand Down

0 comments on commit 95101bf

Please sign in to comment.