本文整理匯總了TypeScript中vs/base/common/arrays.range函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript range函數的具體用法?TypeScript range怎麽用?TypeScript range使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了range函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test
test('all rows get disposed', function () {
const element = document.createElement('div');
element.style.height = '200px';
element.style.width = '200px';
const delegate: IVirtualDelegate<number> = {
getHeight() { return 20; },
getTemplateId() { return 'template'; }
};
let templatesCount = 0;
const renderer: IRenderer<number, void> = {
templateId: 'template',
renderTemplate() { templatesCount++; },
renderElement() { },
disposeElement() { },
disposeTemplate() { templatesCount--; }
};
const listView = new ListView<number>(element, delegate, [renderer]);
listView.layout(200);
assert.equal(templatesCount, 0, 'no templates have been allocated');
listView.splice(0, 0, range(100));
assert.equal(templatesCount, 10, 'some templates have been allocated');
listView.dispose();
assert.equal(templatesCount, 0, 'all templates have been disposed');
});
示例2:
handler: (accessor) => {
const focused = accessor.get(IListService).lastFocusedList;
// List
if (focused instanceof List || focused instanceof PagedList) {
const list = focused;
list.setSelection(range(list.length));
}
}
示例3: model
set model(model: IPagedModel<T>) {
this._model = model;
this.list.splice(0, this.list.length, range(model.length));
}
示例4: if
handler: (accessor) => {
const focused = accessor.get(IListService).lastFocusedList;
// List
if (focused instanceof List || focused instanceof PagedList) {
const list = focused;
list.setSelection(range(list.length));
}
// Trees
else if (focused instanceof ObjectTree || focused instanceof DataTree || focused instanceof AsyncDataTree) {
const tree = focused;
const focus = tree.getFocus();
const selection = tree.getSelection();
// Which element should be considered to start selecting all?
let start: unknown | undefined = undefined;
if (focus.length > 0 && (selection.length === 0 || selection.indexOf(focus[0]) === -1)) {
start = focus[0];
}
if (!start && selection.length > 0) {
start = selection[0];
}
// What is the scope of select all?
let scope: unknown | undefined = undefined;
if (!start) {
scope = undefined;
} else {
const selectedNode = tree.getNode(start);
const parentNode = selectedNode.parent;
if (!parentNode || !parentNode.parent) { // root
scope = undefined;
} else {
scope = parentNode.element;
}
}
const newSelection: unknown[] = [];
const visit = (node: ITreeNode<unknown, unknown>) => {
for (const child of node.children) {
if (child.visible) {
newSelection.push(child.element);
if (!child.collapsed) {
visit(child);
}
}
}
};
// Add the whole scope subtree to the new selection
visit(tree.getNode(scope));
// If the scope isn't the tree root, it should be part of the new selection
if (scope && selection.length === newSelection.length) {
newSelection.unshift(scope);
}
const fakeKeyboardEvent = new KeyboardEvent('keydown');
tree.setSelection(newSelection, fakeKeyboardEvent);
}
}