Skip to content

Commit

Permalink
Fix #44735
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Feb 28, 2018
1 parent 7c5f56f commit 10438e9
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,11 +587,11 @@ declare module 'vscode' {
/**
* Reveal an element. By default revealed element is selected.
*
* In order to not to select, set the option `donotSelect` to `true`.
* In order to not to select, set the option `select` to `false`.
*
* **NOTE:** [TreeDataProvider](#TreeDataProvider) is required to implement [getParent](#TreeDataProvider.getParent) method to access this API.
*/
reveal(element: T, options?: { donotSelect?: boolean }): Thenable<void>;
reveal(element: T, options?: { select?: boolean }): Thenable<void>;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class MainThreadTreeViews extends Disposable implements MainThreadTreeVie
this.viewsService.getTreeViewer(treeViewId).dataProvider = dataProvider;
}

$reveal(treeViewId: string, item: ITreeItem, parentChain: ITreeItem[], options: { donotSelect?: boolean } = { donotSelect: false }): TPromise<void> {
$reveal(treeViewId: string, item: ITreeItem, parentChain: ITreeItem[], options?: { select?: boolean }): TPromise<void> {
return this.viewsService.openView(treeViewId)
.then(() => {
const viewer = this.viewsService.getTreeViewer(treeViewId);
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/node/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export interface MainThreadTextEditorsShape extends IDisposable {
export interface MainThreadTreeViewsShape extends IDisposable {
$registerTreeViewDataProvider(treeViewId: string): void;
$refresh(treeViewId: string, itemsToRefresh?: { [treeItemHandle: string]: ITreeItem }): void;
$reveal(treeViewId: string, treeItem: ITreeItem, parentChain: ITreeItem[], options?: { donotSelect?: boolean }): TPromise<void>;
$reveal(treeViewId: string, treeItem: ITreeItem, parentChain: ITreeItem[], options?: { select?: boolean }): TPromise<void>;
}

export interface MainThreadErrorsShape extends IDisposable {
Expand Down
10 changes: 5 additions & 5 deletions src/vs/workbench/api/node/extHostTreeViews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class ExtHostTreeViews implements ExtHostTreeViewsShape {
registerTreeDataProvider<T>(id: string, dataProvider: vscode.TreeDataProvider<T>, proposedApiFunction: <U>(fn: U) => U): vscode.TreeView<T> {
const treeView = this.createExtHostTreeViewer(id, dataProvider);
return {
reveal: proposedApiFunction((element: T, options?: { donotSelect?: boolean }): Thenable<void> => {
reveal: proposedApiFunction((element: T, options?: { select?: boolean }): Thenable<void> => {
return treeView.reveal(element, options);
}),
dispose: () => {
Expand Down Expand Up @@ -110,12 +110,12 @@ class ExtHostTreeView<T> extends Disposable {
return this.elements.get(treeItemHandle);
}

reveal(element: T, options?: { donotSelect?: boolean }): TPromise<void> {
reveal(element: T, options?: { select?: boolean }): TPromise<void> {
if (typeof this.dataProvider.getParent !== 'function') {
return TPromise.wrapError(new Error(`Required registered TreeDataProvider to implement 'getParent' method to access 'reveal' mehtod`));
}
return this.resolveUnknownParentChain(element)
.then(parentChain => this.resolveTreeItem(element, parentChain[parentChain.length - 1])
.then(parentChain => this.resolveTreeNode(element, parentChain[parentChain.length - 1])
.then(treeNode => this.proxy.$reveal(this.viewId, treeNode.item, parentChain.map(p => p.item), options)));
}

Expand All @@ -126,7 +126,7 @@ class ExtHostTreeView<T> extends Disposable {
return TPromise.as([]);
}
return this.resolveUnknownParentChain(parent)
.then(result => this.resolveTreeItem(parent, result[result.length - 1])
.then(result => this.resolveTreeNode(parent, result[result.length - 1])
.then(parentNode => {
result.push(parentNode);
return result;
Expand All @@ -142,7 +142,7 @@ class ExtHostTreeView<T> extends Disposable {
return asWinJsPromise(() => this.dataProvider.getParent(element));
}

private resolveTreeItem(element: T, parent?: TreeNode): TPromise<TreeNode> {
private resolveTreeNode(element: T, parent?: TreeNode): TPromise<TreeNode> {
return asWinJsPromise(() => this.dataProvider.getTreeItem(element))
.then(extTreeItem => this.createHandle(element, extTreeItem, parent))
.then(handle => this.getChildren(parent ? parent.item.handle : null)
Expand Down
7 changes: 4 additions & 3 deletions src/vs/workbench/browser/parts/views/customView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { FileKind } from 'vs/platform/files/common/files';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { FileIconThemableWorkbenchTree } from 'vs/workbench/browser/parts/views/viewsViewlet';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { isUndefinedOrNull } from 'vs/base/common/types';

export class CustomViewsService extends Disposable implements ICustomViewsService {

Expand Down Expand Up @@ -262,10 +263,10 @@ class CustomTreeViewer extends Disposable implements ITreeViewer {
return TPromise.as(null);
}

reveal(item: ITreeItem, parentChain: ITreeItem[], options?: { donotSelect?: boolean }): TPromise<void> {
reveal(item: ITreeItem, parentChain: ITreeItem[], options?: { select?: boolean }): TPromise<void> {
if (this.tree && this.isVisible) {
options = options ? options : { donotSelect: false };
const select = !options.donotSelect;
options = options ? options : { select: true };
const select = isUndefinedOrNull(options.select) ? true : options.select;
var result = TPromise.as(null);
parentChain.forEach((e) => {
result = result.then(() => this.tree.expand(e));
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/common/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export interface ITreeViewer extends IDisposable {

getOptimalWidth(): number;

reveal(item: ITreeItem, parentChain: ITreeItem[], options: { donotSelect?: boolean }): TPromise<void>;
reveal(item: ITreeItem, parentChain: ITreeItem[], options: { select?: boolean }): TPromise<void>;
}

export interface ICustomViewDescriptor extends IViewDescriptor {
Expand Down

0 comments on commit 10438e9

Please sign in to comment.