mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
highlight correct notebook on navigation. (#10807)
* highlight correct notebook on navigation. * add back behavior of highight on viewlet visible * optimize bookViewer create * createTreeView for every book
This commit is contained in:
@@ -51,7 +51,7 @@ export class BookModel implements azdata.nb.NavigationProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getNotebook(uri: string): BookTreeItem | undefined {
|
public getNotebook(uri: string): BookTreeItem | undefined {
|
||||||
return this._allNotebooks.get(uri);
|
return this._allNotebooks.get(this.openAsUntitled ? path.basename(uri) : uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async loadTableOfContentFiles(folderPath: string): Promise<void> {
|
public async loadTableOfContentFiles(folderPath: string): Promise<void> {
|
||||||
@@ -190,8 +190,8 @@ export class BookModel implements azdata.nb.NavigationProvider {
|
|||||||
if (this.openAsUntitled) {
|
if (this.openAsUntitled) {
|
||||||
if (!this._allNotebooks.get(path.basename(pathToNotebook))) {
|
if (!this._allNotebooks.get(path.basename(pathToNotebook))) {
|
||||||
this._allNotebooks.set(path.basename(pathToNotebook), notebook);
|
this._allNotebooks.set(path.basename(pathToNotebook), notebook);
|
||||||
notebooks.push(notebook);
|
|
||||||
}
|
}
|
||||||
|
notebooks.push(notebook);
|
||||||
} else {
|
} else {
|
||||||
// convert to URI to avoid casing issue with drive letters when getting navigation links
|
// convert to URI to avoid casing issue with drive letters when getting navigation links
|
||||||
let uriToNotebook: vscode.Uri = vscode.Uri.file(pathToNotebook);
|
let uriToNotebook: vscode.Uri = vscode.Uri.file(pathToNotebook);
|
||||||
|
|||||||
@@ -183,9 +183,6 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
|||||||
this.revealActiveDocumentInViewlet();
|
this.revealActiveDocumentInViewlet();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
azdata.nb.onDidChangeActiveNotebookEditor(e => {
|
|
||||||
this.revealActiveDocumentInViewlet(e.document.uri, false);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async showPreviewFile(urlToOpen?: string): Promise<void> {
|
async showPreviewFile(urlToOpen?: string): Promise<void> {
|
||||||
@@ -235,10 +232,12 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
|||||||
if (!uri) {
|
if (!uri) {
|
||||||
let openDocument = azdata.nb.activeNotebookEditor;
|
let openDocument = azdata.nb.activeNotebookEditor;
|
||||||
if (openDocument) {
|
if (openDocument) {
|
||||||
bookItem = this.currentBook?.getNotebook(openDocument.document.uri.fsPath);
|
let book = this.books.find(b => openDocument.document.uri.fsPath.replace(/\\/g, '/').toLowerCase().indexOf(b.bookPath.toLowerCase()) > -1);
|
||||||
|
bookItem = book?.getNotebook(openDocument.document.uri.fsPath);
|
||||||
}
|
}
|
||||||
} else if (uri.fsPath) {
|
} else if (uri.fsPath) {
|
||||||
bookItem = this.currentBook?.getNotebook(uri.fsPath);
|
let book = this.books.find(b => uri.fsPath.replace(/\\/g, '/').toLowerCase().indexOf(b.bookPath.toLowerCase()) > -1);
|
||||||
|
bookItem = book?.getNotebook(uri.fsPath);
|
||||||
}
|
}
|
||||||
if (bookItem) {
|
if (bookItem) {
|
||||||
// Select + focus item in viewlet if books viewlet is already open, or if we pass in variable
|
// Select + focus item in viewlet if books viewlet is already open, or if we pass in variable
|
||||||
|
|||||||
@@ -129,6 +129,14 @@ export async function activate(extensionContext: vscode.ExtensionContext): Promi
|
|||||||
const providedBookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [], extensionContext, true, PROVIDED_BOOKS_VIEWID);
|
const providedBookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [], extensionContext, true, PROVIDED_BOOKS_VIEWID);
|
||||||
await providedBookTreeViewProvider.initialized;
|
await providedBookTreeViewProvider.initialized;
|
||||||
|
|
||||||
|
azdata.nb.onDidChangeActiveNotebookEditor(e => {
|
||||||
|
if (e.document.uri.scheme === 'untitled') {
|
||||||
|
providedBookTreeViewProvider.revealActiveDocumentInViewlet(e.document.uri, false);
|
||||||
|
} else {
|
||||||
|
bookTreeViewProvider.revealActiveDocumentInViewlet(e.document.uri, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
extensionContext.subscriptions.push(vscode.window.registerTreeDataProvider(BOOKS_VIEWID, bookTreeViewProvider));
|
extensionContext.subscriptions.push(vscode.window.registerTreeDataProvider(BOOKS_VIEWID, bookTreeViewProvider));
|
||||||
extensionContext.subscriptions.push(vscode.window.registerTreeDataProvider(PROVIDED_BOOKS_VIEWID, providedBookTreeViewProvider));
|
extensionContext.subscriptions.push(vscode.window.registerTreeDataProvider(PROVIDED_BOOKS_VIEWID, providedBookTreeViewProvider));
|
||||||
|
|||||||
Reference in New Issue
Block a user