提交 615c24ca 编写于 作者: B Bailey

Add explorerView check to see if element is visible

上级 6bf9cc1e
......@@ -1546,6 +1546,16 @@ export class List<T> implements ISpliceable<T>, IDisposable {
return this.getFocus().map(i => this.view.element(i));
}
isElementVisible(index: number) {
const viewTop = this.view.getScrollTop();
const viewBottom = this.view.renderHeight + viewTop;
const elementTop = this.view.elementTop(index);
const elementBottom = this.view.elementHeight(index) + elementTop;
return (elementTop >= viewTop && elementBottom <= viewBottom);
}
reveal(index: number, relativeTop?: number): void {
if (index < 0 || index >= this.length) {
throw new ListError(this.user, `Invalid index ${index}`);
......
......@@ -1589,6 +1589,19 @@ export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable
this.view.open(indexes, browserEvent);
}
isElementVisible(location: TRef) {
const index = this.model.getListIndex(location);
if (index === -1) {
return false;
}
const parentNode = this.model.getNode(this.model.getParentNodeLocation(location));
const parentCollapsed = !parentNode.visible || parentNode.collapsed;
return this.view.isElementVisible(index) && !parentCollapsed;
}
reveal(location: TRef, relativeTop?: number): void {
this.model.expandTo(location);
......
......@@ -662,6 +662,10 @@ export class AsyncDataTree<TInput, T, TFilterData = void> implements IDisposable
this.tree.open(nodes, browserEvent);
}
isElementVisible(element: T) {
return this.tree.isElementVisible(this.getDataNode(element));
}
reveal(element: T, relativeTop?: number): void {
this.tree.reveal(this.getDataNode(element), relativeTop);
}
......
......@@ -675,7 +675,11 @@ export class ExplorerView extends ViewPane {
if (item.isDisposed) {
return this.onSelectResource(resource, reveal, retry + 1);
}
this.tree.reveal(item, 0.5);
// Don't scroll to the item if it's already visible
if (!this.tree.isElementVisible(item)) {
this.tree.reveal(item, 0.5);
}
}
this.tree.setFocus([item]);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册