mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Test/highlight correct nb (#11348)
* unit test of the method * stash changes * revealActiveDocumentInViewlet test * separate tests * test on activate * added tests * feedback changes * naming change
This commit is contained in:
@@ -230,7 +230,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
||||
}
|
||||
}
|
||||
|
||||
async revealActiveDocumentInViewlet(uri?: vscode.Uri, shouldReveal: boolean = true): Promise<void> {
|
||||
async revealActiveDocumentInViewlet(uri?: vscode.Uri, shouldReveal: boolean = true): Promise<BookTreeItem | undefined> {
|
||||
let bookItem: BookTreeItem;
|
||||
let notebookPath: string;
|
||||
// If no uri is passed in, try to use the current active notebook editor
|
||||
@@ -242,15 +242,16 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
||||
} else if (uri.fsPath) {
|
||||
notebookPath = uri.fsPath;
|
||||
}
|
||||
bookItem = notebookPath ? await this.findAndExpandParentNode(notebookPath) : undefined;
|
||||
|
||||
if (bookItem) {
|
||||
if (shouldReveal || this._bookViewer.visible) {
|
||||
bookItem = notebookPath ? await this.findAndExpandParentNode(notebookPath) : undefined;
|
||||
// Select + focus item in viewlet if books viewlet is already open, or if we pass in variable
|
||||
if (shouldReveal || this._bookViewer.visible) {
|
||||
if (bookItem) {
|
||||
// Note: 3 is the maximum number of levels that the vscode APIs let you expand to
|
||||
await this._bookViewer.reveal(bookItem, { select: true, focus: true, expand: true });
|
||||
}
|
||||
}
|
||||
return bookItem;
|
||||
}
|
||||
|
||||
async findAndExpandParentNode(notebookPath: string): Promise<BookTreeItem> {
|
||||
@@ -535,9 +536,4 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
||||
}
|
||||
return Promise.resolve(result);
|
||||
}
|
||||
|
||||
public getBookFromItemPath(itemPath: string): BookModel | undefined {
|
||||
let selectedBook = this.books.find(b => itemPath.toLowerCase().indexOf(b.bookPath.toLowerCase()) > -1);
|
||||
return selectedBook;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user