mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
fixes https://github.com/microsoft/vscode/issues/161618
This commit is contained in:
parent
dfca1cc002
commit
2428297798
|
@ -576,12 +576,16 @@ export class TernarySearchTree<K, V> {
|
|||
if (!node.mid && !node.value) {
|
||||
if (node.left && node.right) {
|
||||
// full node
|
||||
// replace deleted-node with the min-node of the right branch.
|
||||
// If there is no true min-node leave things as they are
|
||||
const min = this._min(node.right);
|
||||
const { key, value, segment } = min;
|
||||
this._delete(min.key!, false);
|
||||
node.key = key;
|
||||
node.value = value;
|
||||
node.segment = segment;
|
||||
if (min.key) {
|
||||
const { key, value, segment } = min;
|
||||
this._delete(min.key!, false);
|
||||
node.key = key;
|
||||
node.value = value;
|
||||
node.segment = segment;
|
||||
}
|
||||
|
||||
} else {
|
||||
// empty or half empty
|
||||
|
|
|
@ -862,6 +862,49 @@ suite('Map', () => {
|
|||
}
|
||||
});
|
||||
|
||||
test('TernarySearchTree: Cannot read properties of undefined (reading \'length\'): #161618 (simple)', function () {
|
||||
const raw = 'config.debug.toolBarLocation,floating,config.editor.renderControlCharacters,true,config.editor.renderWhitespace,selection,config.files.autoSave,off,config.git.enabled,true,config.notebook.globalToolbar,true,config.terminal.integrated.tabs.enabled,true,config.terminal.integrated.tabs.showActions,singleTerminalOrNarrow,config.terminal.integrated.tabs.showActiveTerminal,singleTerminalOrNarrow,config.workbench.activityBar.visible,true,config.workbench.experimental.settingsProfiles.enabled,true,config.workbench.layoutControl.type,both,config.workbench.sideBar.location,left,config.workbench.statusBar.visible,true';
|
||||
const array = raw.split(',');
|
||||
const tuples: [string, string][] = [];
|
||||
for (let i = 0; i < array.length; i += 2) {
|
||||
tuples.push([array[i], array[i + 1]]);
|
||||
}
|
||||
|
||||
const map = TernarySearchTree.forConfigKeys<string>();
|
||||
map.fill(tuples);
|
||||
|
||||
assert.strictEqual([...map].join(), raw);
|
||||
assert.ok(map.has('config.editor.renderWhitespace'));
|
||||
|
||||
const len = [...map].length;
|
||||
map.delete('config.editor.renderWhitespace');
|
||||
assert.ok(map._isBalanced());
|
||||
assert.strictEqual([...map].length, len - 1);
|
||||
});
|
||||
|
||||
test('TernarySearchTree: Cannot read properties of undefined (reading \'length\'): #161618 (random)', function () {
|
||||
const raw = 'config.debug.toolBarLocation,floating,config.editor.renderControlCharacters,true,config.editor.renderWhitespace,selection,config.files.autoSave,off,config.git.enabled,true,config.notebook.globalToolbar,true,config.terminal.integrated.tabs.enabled,true,config.terminal.integrated.tabs.showActions,singleTerminalOrNarrow,config.terminal.integrated.tabs.showActiveTerminal,singleTerminalOrNarrow,config.workbench.activityBar.visible,true,config.workbench.experimental.settingsProfiles.enabled,true,config.workbench.layoutControl.type,both,config.workbench.sideBar.location,left,config.workbench.statusBar.visible,true';
|
||||
const array = raw.split(',');
|
||||
const tuples: [string, string][] = [];
|
||||
for (let i = 0; i < array.length; i += 2) {
|
||||
tuples.push([array[i], array[i + 1]]);
|
||||
}
|
||||
|
||||
for (let round = 100; round >= 0; round--) {
|
||||
shuffle(tuples);
|
||||
const map = TernarySearchTree.forConfigKeys<string>();
|
||||
map.fill(tuples);
|
||||
|
||||
assert.strictEqual([...map].join(), raw);
|
||||
assert.ok(map.has('config.editor.renderWhitespace'));
|
||||
|
||||
const len = [...map].length;
|
||||
map.delete('config.editor.renderWhitespace');
|
||||
assert.ok(map._isBalanced());
|
||||
assert.strictEqual([...map].length, len - 1);
|
||||
}
|
||||
});
|
||||
|
||||
test('TernarySearchTree (PathSegments) - lookup', function () {
|
||||
|
||||
const map = new TernarySearchTree<string, number>(new PathIterator());
|
||||
|
|
Loading…
Reference in a new issue