mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Ensure Active File is Highlighted in Books Viewlet (#9338)
* Add Reveal in Books editor tab context option * Select item in books viewlet automatically * changes * easier than i thought it'd be * Merge from Feat/create book * Undo Merge from Feat/create book * Use fsPath instead of path * PR comments * Fix tests Co-authored-by: Maddy <12754347+MaddyDev@users.noreply.github.com>
This commit is contained in:
@@ -145,6 +145,11 @@
|
|||||||
"title": "%title.PreviewLocalizedBook%",
|
"title": "%title.PreviewLocalizedBook%",
|
||||||
"category": "%books-preview-category%"
|
"category": "%books-preview-category%"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "notebook.command.revealInBooksViewlet",
|
||||||
|
"title": "%title.revealInBooksViewlet%",
|
||||||
|
"category": "%books-preview-category%"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "notebook.command.saveBook",
|
"command": "notebook.command.saveBook",
|
||||||
"title": "%title.saveJupyterBook%",
|
"title": "%title.saveJupyterBook%",
|
||||||
@@ -282,6 +287,10 @@
|
|||||||
{
|
{
|
||||||
"command": "notebook.command.searchUntitledBook",
|
"command": "notebook.command.searchUntitledBook",
|
||||||
"when": "false"
|
"when": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "notebook.command.revealInBooksViewlet",
|
||||||
|
"when": "false"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"touchBar": [
|
"touchBar": [
|
||||||
|
|||||||
@@ -35,5 +35,6 @@
|
|||||||
"title.UnsavedBooks": "Unsaved Books",
|
"title.UnsavedBooks": "Unsaved Books",
|
||||||
"title.PreviewLocalizedBook": "Get localized SQL Server 2019 guide",
|
"title.PreviewLocalizedBook": "Get localized SQL Server 2019 guide",
|
||||||
"title.openJupyterBook": "Open Jupyter Book",
|
"title.openJupyterBook": "Open Jupyter Book",
|
||||||
|
"title.revealInBooksViewlet": "Reveal in Books",
|
||||||
"title.createJupyterBook": "Create Book"
|
"title.createJupyterBook": "Create Book"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,10 +41,14 @@ export class BookModel implements azdata.nb.NavigationProvider {
|
|||||||
await this.readBooks();
|
await this.readBooks();
|
||||||
}
|
}
|
||||||
|
|
||||||
public getAllBooks(): Map<string, BookTreeItem> {
|
public getAllNotebooks(): Map<string, BookTreeItem> {
|
||||||
return this._allNotebooks;
|
return this._allNotebooks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getNotebook(uri: string): BookTreeItem | undefined {
|
||||||
|
return this._allNotebooks.get(uri);
|
||||||
|
}
|
||||||
|
|
||||||
public async getTableOfContentFiles(folderPath: string): Promise<void> {
|
public async getTableOfContentFiles(folderPath: string): Promise<void> {
|
||||||
let notebookConfig = vscode.workspace.getConfiguration(notebookConfigKey);
|
let notebookConfig = vscode.workspace.getConfiguration(notebookConfigKey);
|
||||||
let maxDepth = notebookConfig[maxBookSearchDepth];
|
let maxDepth = notebookConfig[maxBookSearchDepth];
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { BookTreeItem } from './bookTreeItem';
|
|||||||
import { BookModel } from './bookModel';
|
import { BookModel } from './bookModel';
|
||||||
import { Deferred } from '../common/promise';
|
import { Deferred } from '../common/promise';
|
||||||
import * as loc from '../common/localizedConstants';
|
import * as loc from '../common/localizedConstants';
|
||||||
|
import { ApiWrapper } from '../common/apiWrapper';
|
||||||
|
|
||||||
const Content = 'content';
|
const Content = 'content';
|
||||||
|
|
||||||
@@ -25,20 +26,21 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
|||||||
private _extensionContext: vscode.ExtensionContext;
|
private _extensionContext: vscode.ExtensionContext;
|
||||||
private prompter: IPrompter;
|
private prompter: IPrompter;
|
||||||
private _initializeDeferred: Deferred<void> = new Deferred<void>();
|
private _initializeDeferred: Deferred<void> = new Deferred<void>();
|
||||||
|
private _bookViewer: vscode.TreeView<BookTreeItem>;
|
||||||
private _openAsUntitled: boolean;
|
private _openAsUntitled: boolean;
|
||||||
|
private _apiWrapper: ApiWrapper;
|
||||||
public viewId: string;
|
public viewId: string;
|
||||||
public books: BookModel[];
|
public books: BookModel[];
|
||||||
public currentBook: BookModel;
|
public currentBook: BookModel;
|
||||||
|
|
||||||
constructor(workspaceFolders: vscode.WorkspaceFolder[], extensionContext: vscode.ExtensionContext, openAsUntitled: boolean, view: string) {
|
constructor(apiWrapper: ApiWrapper, workspaceFolders: vscode.WorkspaceFolder[], extensionContext: vscode.ExtensionContext, openAsUntitled: boolean, view: string) {
|
||||||
this._openAsUntitled = openAsUntitled;
|
this._openAsUntitled = openAsUntitled;
|
||||||
this._extensionContext = extensionContext;
|
this._extensionContext = extensionContext;
|
||||||
this.books = [];
|
this.books = [];
|
||||||
this.initialize(workspaceFolders).catch(e => console.error(e));
|
this.initialize(workspaceFolders).catch(e => console.error(e));
|
||||||
this.viewId = view;
|
this.viewId = view;
|
||||||
this.prompter = new CodeAdapter();
|
this.prompter = new CodeAdapter();
|
||||||
|
this._apiWrapper = apiWrapper ? apiWrapper : new ApiWrapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async initialize(workspaceFolders: vscode.WorkspaceFolder[]): Promise<void> {
|
private async initialize(workspaceFolders: vscode.WorkspaceFolder[]): Promise<void> {
|
||||||
@@ -89,6 +91,15 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
|||||||
if (!this.currentBook) {
|
if (!this.currentBook) {
|
||||||
this.currentBook = book;
|
this.currentBook = book;
|
||||||
}
|
}
|
||||||
|
this._bookViewer = this._apiWrapper.createTreeView(this.viewId, { showCollapseAll: true, treeDataProvider: this });
|
||||||
|
this._bookViewer.onDidChangeVisibility(e => {
|
||||||
|
if (e.visible) {
|
||||||
|
this.revealActiveDocumentInViewlet();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
azdata.nb.onDidChangeActiveNotebookEditor(e => {
|
||||||
|
this.revealActiveDocumentInViewlet(e.document.uri, false);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async showPreviewFile(urlToOpen?: string): Promise<void> {
|
async showPreviewFile(urlToOpen?: string): Promise<void> {
|
||||||
@@ -121,6 +132,26 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async revealActiveDocumentInViewlet(uri?: vscode.Uri, shouldReveal: boolean = true): Promise<void> {
|
||||||
|
let bookItem: BookTreeItem;
|
||||||
|
// If no uri is passed in, try to use the current active notebook editor
|
||||||
|
if (!uri) {
|
||||||
|
let openDocument = azdata.nb.activeNotebookEditor;
|
||||||
|
if (openDocument) {
|
||||||
|
bookItem = this.currentBook.getNotebook(openDocument.document.uri.fsPath);
|
||||||
|
}
|
||||||
|
} else if (uri.fsPath) {
|
||||||
|
bookItem = this.currentBook.getNotebook(uri.fsPath);
|
||||||
|
}
|
||||||
|
if (bookItem) {
|
||||||
|
// Select + focus item in viewlet if books viewlet is already open, or if we pass in variable
|
||||||
|
if (shouldReveal || this._bookViewer.visible) {
|
||||||
|
// 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: 3 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
openMarkdown(resource: string): void {
|
openMarkdown(resource: string): void {
|
||||||
this.runThrottledAction(resource, () => {
|
this.runThrottledAction(resource, () => {
|
||||||
try {
|
try {
|
||||||
@@ -289,7 +320,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
|||||||
else {
|
else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
return this.currentBook.getAllBooks().get(parentPath);
|
return this.currentBook.getAllNotebooks().get(parentPath);
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@@ -297,9 +328,9 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
|||||||
|
|
||||||
getUntitledNotebookUri(resource: string): vscode.Uri {
|
getUntitledNotebookUri(resource: string): vscode.Uri {
|
||||||
let untitledFileName = vscode.Uri.parse(`untitled:${resource}`);
|
let untitledFileName = vscode.Uri.parse(`untitled:${resource}`);
|
||||||
if (!this.currentBook.getAllBooks().get(untitledFileName.fsPath) && !this.currentBook.getAllBooks().get(path.basename(untitledFileName.fsPath))) {
|
if (!this.currentBook.getAllNotebooks().get(untitledFileName.fsPath) && !this.currentBook.getAllNotebooks().get(path.basename(untitledFileName.fsPath))) {
|
||||||
let notebook = this.currentBook.getAllBooks().get(resource);
|
let notebook = this.currentBook.getAllNotebooks().get(resource);
|
||||||
this.currentBook.getAllBooks().set(path.basename(untitledFileName.fsPath), notebook);
|
this.currentBook.getAllNotebooks().set(path.basename(untitledFileName.fsPath), notebook);
|
||||||
}
|
}
|
||||||
return untitledFileName;
|
return untitledFileName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,4 +83,8 @@ export class ApiWrapper {
|
|||||||
public parseUri(uri: string): vscode.Uri {
|
public parseUri(uri: string): vscode.Uri {
|
||||||
return vscode.Uri.parse(uri);
|
return vscode.Uri.parse(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public createTreeView<T>(viewId: string, options: vscode.TreeViewOptions<T>): vscode.TreeView<T> {
|
||||||
|
return vscode.window.createTreeView(viewId, options);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,6 +109,9 @@ export async function activate(extensionContext: vscode.ExtensionContext): Promi
|
|||||||
await vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(urlToOpen));
|
await vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(urlToOpen));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.revealInBooksViewlet', (uri: vscode.Uri, shouldReveal: boolean) => bookTreeViewProvider.revealActiveDocumentInViewlet(uri, shouldReveal)));
|
||||||
|
extensionContext.subscriptions.push(vscode.commands.registerCommand('notebook.command.revealInUntitledBooksViewlet', (uri: vscode.Uri, shouldReveal: boolean) => untitledBookTreeViewProvider.revealActiveDocumentInViewlet(uri, shouldReveal)));
|
||||||
|
|
||||||
let appContext = new AppContext(extensionContext, new ApiWrapper());
|
let appContext = new AppContext(extensionContext, new ApiWrapper());
|
||||||
controller = new JupyterController(appContext);
|
controller = new JupyterController(appContext);
|
||||||
let result = await controller.activate();
|
let result = await controller.activate();
|
||||||
@@ -117,14 +120,11 @@ export async function activate(extensionContext: vscode.ExtensionContext): Promi
|
|||||||
}
|
}
|
||||||
|
|
||||||
let workspaceFolders = vscode.workspace.workspaceFolders?.slice() ?? [];
|
let workspaceFolders = vscode.workspace.workspaceFolders?.slice() ?? [];
|
||||||
const bookTreeViewProvider = new BookTreeViewProvider(workspaceFolders, extensionContext, false, BOOKS_VIEWID);
|
const bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, workspaceFolders, extensionContext, false, BOOKS_VIEWID);
|
||||||
await bookTreeViewProvider.initialized;
|
await bookTreeViewProvider.initialized;
|
||||||
const untitledBookTreeViewProvider = new BookTreeViewProvider([], extensionContext, true, READONLY_BOOKS_VIEWID);
|
const untitledBookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [], extensionContext, true, READONLY_BOOKS_VIEWID);
|
||||||
await untitledBookTreeViewProvider.initialized;
|
await untitledBookTreeViewProvider.initialized;
|
||||||
|
|
||||||
extensionContext.subscriptions.push(vscode.window.registerTreeDataProvider(BOOKS_VIEWID, bookTreeViewProvider));
|
|
||||||
extensionContext.subscriptions.push(vscode.window.registerTreeDataProvider(READONLY_BOOKS_VIEWID, untitledBookTreeViewProvider));
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getJupyterController() {
|
getJupyterController() {
|
||||||
return controller;
|
return controller;
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import { BookTreeItem } from '../../book/bookTreeItem';
|
|||||||
import { promisify } from 'util';
|
import { promisify } from 'util';
|
||||||
import { MockExtensionContext } from '../common/stubs';
|
import { MockExtensionContext } from '../common/stubs';
|
||||||
import { exists } from '../../common/utils';
|
import { exists } from '../../common/utils';
|
||||||
|
import { AppContext } from '../../common/appContext';
|
||||||
|
import { ApiWrapper } from '../../common/apiWrapper';
|
||||||
|
|
||||||
export interface IExpectedBookItem {
|
export interface IExpectedBookItem {
|
||||||
title: string;
|
title: string;
|
||||||
@@ -52,6 +54,7 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
let expectedMarkdown: IExpectedBookItem;
|
let expectedMarkdown: IExpectedBookItem;
|
||||||
let expectedExternalLink: IExpectedBookItem;
|
let expectedExternalLink: IExpectedBookItem;
|
||||||
let expectedBook: IExpectedBookItem;
|
let expectedBook: IExpectedBookItem;
|
||||||
|
let appContext: AppContext;
|
||||||
|
|
||||||
this.beforeAll(async () => {
|
this.beforeAll(async () => {
|
||||||
mockExtensionContext = new MockExtensionContext();
|
mockExtensionContext = new MockExtensionContext();
|
||||||
@@ -98,6 +101,8 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
sections: [expectedNotebook1, expectedMarkdown, expectedExternalLink],
|
sections: [expectedNotebook1, expectedMarkdown, expectedExternalLink],
|
||||||
title: 'Test Book'
|
title: 'Test Book'
|
||||||
};
|
};
|
||||||
|
appContext = new AppContext(mockExtensionContext, new ApiWrapper());
|
||||||
|
|
||||||
await fs.mkdir(rootFolderPath);
|
await fs.mkdir(rootFolderPath);
|
||||||
await fs.mkdir(bookFolderPath);
|
await fs.mkdir(bookFolderPath);
|
||||||
await fs.mkdir(nonBookFolderPath);
|
await fs.mkdir(nonBookFolderPath);
|
||||||
@@ -112,7 +117,7 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should initialize correctly with empty workspace array', async () => {
|
it('should initialize correctly with empty workspace array', async () => {
|
||||||
const bookTreeViewProvider = new BookTreeViewProvider([], mockExtensionContext, false, 'bookTreeView');
|
const bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [], mockExtensionContext, false, 'bookTreeView');
|
||||||
await bookTreeViewProvider.initialized;
|
await bookTreeViewProvider.initialized;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -122,7 +127,7 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
name: '',
|
name: '',
|
||||||
index: 0
|
index: 0
|
||||||
};
|
};
|
||||||
const bookTreeViewProvider = new BookTreeViewProvider([folder], mockExtensionContext, false, 'bookTreeView');
|
const bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [folder], mockExtensionContext, false, 'bookTreeView');
|
||||||
await bookTreeViewProvider.initialized;
|
await bookTreeViewProvider.initialized;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -137,7 +142,7 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
name: '',
|
name: '',
|
||||||
index: 0
|
index: 0
|
||||||
};
|
};
|
||||||
const bookTreeViewProvider = new BookTreeViewProvider([book, nonBook], mockExtensionContext, false, 'bookTreeView');
|
const bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [book, nonBook], mockExtensionContext, false, 'bookTreeView');
|
||||||
await bookTreeViewProvider.initialized;
|
await bookTreeViewProvider.initialized;
|
||||||
should(bookTreeViewProvider.books.length).equal(1, 'Expected book was not initialized');
|
should(bookTreeViewProvider.books.length).equal(1, 'Expected book was not initialized');
|
||||||
});
|
});
|
||||||
@@ -153,7 +158,7 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
name: '',
|
name: '',
|
||||||
index: 0
|
index: 0
|
||||||
};
|
};
|
||||||
bookTreeViewProvider = new BookTreeViewProvider([folder], mockExtensionContext, false, 'bookTreeView');
|
bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [folder], mockExtensionContext, false, 'bookTreeView');
|
||||||
let errorCase = new Promise((resolve, reject) => setTimeout(() => resolve(), 5000));
|
let errorCase = new Promise((resolve, reject) => setTimeout(() => resolve(), 5000));
|
||||||
await Promise.race([bookTreeViewProvider.initialized, errorCase.then(() => { throw new Error('BookTreeViewProvider did not initialize in time'); })]);
|
await Promise.race([bookTreeViewProvider.initialized, errorCase.then(() => { throw new Error('BookTreeViewProvider did not initialize in time'); })]);
|
||||||
});
|
});
|
||||||
@@ -204,6 +209,7 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
let tableOfContentsFile: string;
|
let tableOfContentsFile: string;
|
||||||
let bookTreeViewProvider: BookTreeViewProvider;
|
let bookTreeViewProvider: BookTreeViewProvider;
|
||||||
let folder: vscode.WorkspaceFolder;
|
let folder: vscode.WorkspaceFolder;
|
||||||
|
let appContext: AppContext;
|
||||||
|
|
||||||
this.beforeAll(async () => {
|
this.beforeAll(async () => {
|
||||||
rootFolderPath = path.join(os.tmpdir(), `BookTestData_${uuid.v4()}`);
|
rootFolderPath = path.join(os.tmpdir(), `BookTestData_${uuid.v4()}`);
|
||||||
@@ -220,7 +226,8 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
name: '',
|
name: '',
|
||||||
index: 0
|
index: 0
|
||||||
};
|
};
|
||||||
bookTreeViewProvider = new BookTreeViewProvider([folder], mockExtensionContext, false, 'bookTreeView');
|
appContext = new AppContext(mockExtensionContext, new ApiWrapper());
|
||||||
|
bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [folder], mockExtensionContext, false, 'bookTreeView');
|
||||||
let errorCase = new Promise((resolve, reject) => setTimeout(() => resolve(), 5000));
|
let errorCase = new Promise((resolve, reject) => setTimeout(() => resolve(), 5000));
|
||||||
await Promise.race([bookTreeViewProvider.initialized, errorCase.then(() => { throw new Error('BookTreeViewProvider did not initialize in time'); })]);
|
await Promise.race([bookTreeViewProvider.initialized, errorCase.then(() => { throw new Error('BookTreeViewProvider did not initialize in time'); })]);
|
||||||
});
|
});
|
||||||
@@ -246,6 +253,7 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
let folder: vscode.WorkspaceFolder;
|
let folder: vscode.WorkspaceFolder;
|
||||||
let bookTreeViewProvider: BookTreeViewProvider;
|
let bookTreeViewProvider: BookTreeViewProvider;
|
||||||
let tocFile: string;
|
let tocFile: string;
|
||||||
|
let appContext: AppContext;
|
||||||
|
|
||||||
this.beforeAll(async () => {
|
this.beforeAll(async () => {
|
||||||
rootFolderPath = path.join(os.tmpdir(), `BookTestData_${uuid.v4()}`);
|
rootFolderPath = path.join(os.tmpdir(), `BookTestData_${uuid.v4()}`);
|
||||||
@@ -261,7 +269,8 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
name: '',
|
name: '',
|
||||||
index: 0
|
index: 0
|
||||||
};
|
};
|
||||||
bookTreeViewProvider = new BookTreeViewProvider([folder], mockExtensionContext, false, 'bookTreeView');
|
appContext = new AppContext(mockExtensionContext, new ApiWrapper());
|
||||||
|
bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [folder], mockExtensionContext, false, 'bookTreeView');
|
||||||
let errorCase = new Promise((resolve, reject) => setTimeout(() => resolve(), 5000));
|
let errorCase = new Promise((resolve, reject) => setTimeout(() => resolve(), 5000));
|
||||||
await Promise.race([bookTreeViewProvider.initialized, errorCase.then(() => { throw new Error('BookTreeViewProvider did not initialize in time'); })]);
|
await Promise.race([bookTreeViewProvider.initialized, errorCase.then(() => { throw new Error('BookTreeViewProvider did not initialize in time'); })]);
|
||||||
});
|
});
|
||||||
@@ -291,6 +300,7 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
let bookTreeViewProvider: BookTreeViewProvider;
|
let bookTreeViewProvider: BookTreeViewProvider;
|
||||||
let folder: vscode.WorkspaceFolder;
|
let folder: vscode.WorkspaceFolder;
|
||||||
let expectedNotebook2: IExpectedBookItem;
|
let expectedNotebook2: IExpectedBookItem;
|
||||||
|
let appContext: AppContext;
|
||||||
|
|
||||||
this.beforeAll(async () => {
|
this.beforeAll(async () => {
|
||||||
rootFolderPath = path.join(os.tmpdir(), `BookTestData_${uuid.v4()}`);
|
rootFolderPath = path.join(os.tmpdir(), `BookTestData_${uuid.v4()}`);
|
||||||
@@ -318,7 +328,8 @@ describe('BookTreeViewProviderTests', function () {
|
|||||||
name: '',
|
name: '',
|
||||||
index: 0
|
index: 0
|
||||||
};
|
};
|
||||||
bookTreeViewProvider = new BookTreeViewProvider([folder], mockExtensionContext, false, 'bookTreeView');
|
appContext = new AppContext(mockExtensionContext, new ApiWrapper());
|
||||||
|
bookTreeViewProvider = new BookTreeViewProvider(appContext.apiWrapper, [folder], mockExtensionContext, false, 'bookTreeView');
|
||||||
let errorCase = new Promise((resolve, reject) => setTimeout(() => resolve(), 5000));
|
let errorCase = new Promise((resolve, reject) => setTimeout(() => resolve(), 5000));
|
||||||
await Promise.race([bookTreeViewProvider.initialized, errorCase.then(() => { throw new Error('BookTreeViewProvider did not initialize in time'); })]);
|
await Promise.race([bookTreeViewProvider.initialized, errorCase.then(() => { throw new Error('BookTreeViewProvider did not initialize in time'); })]);
|
||||||
});
|
});
|
||||||
|
|||||||
8
src/sql/azdata.proposed.d.ts
vendored
8
src/sql/azdata.proposed.d.ts
vendored
@@ -206,4 +206,12 @@ declare module 'azdata' {
|
|||||||
export interface CheckBoxProperties {
|
export interface CheckBoxProperties {
|
||||||
required?: boolean;
|
required?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export namespace nb {
|
||||||
|
/**
|
||||||
|
* An event that is emitted when the active Notebook editor is changed.
|
||||||
|
*/
|
||||||
|
export const onDidChangeActiveNotebookEditor: vscode.Event<NotebookEditor>;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -488,6 +488,9 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
|
|||||||
get onDidOpenNotebookDocument() {
|
get onDidOpenNotebookDocument() {
|
||||||
return extHostNotebookDocumentsAndEditors.onDidOpenNotebookDocument;
|
return extHostNotebookDocumentsAndEditors.onDidOpenNotebookDocument;
|
||||||
},
|
},
|
||||||
|
get onDidChangeActiveNotebookEditor() {
|
||||||
|
return extHostNotebookDocumentsAndEditors.onDidChangeActiveNotebookEditor;
|
||||||
|
},
|
||||||
get onDidChangeNotebookCell() {
|
get onDidChangeNotebookCell() {
|
||||||
return extHostNotebookDocumentsAndEditors.onDidChangeNotebookCell;
|
return extHostNotebookDocumentsAndEditors.onDidChangeNotebookCell;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ import { find, firstIndex } from 'vs/base/common/arrays';
|
|||||||
import { CodeCellComponent } from 'sql/workbench/contrib/notebook/browser/cellViews/codeCell.component';
|
import { CodeCellComponent } from 'sql/workbench/contrib/notebook/browser/cellViews/codeCell.component';
|
||||||
import { TextCellComponent } from 'sql/workbench/contrib/notebook/browser/cellViews/textCell.component';
|
import { TextCellComponent } from 'sql/workbench/contrib/notebook/browser/cellViews/textCell.component';
|
||||||
import { NotebookInput } from 'sql/workbench/contrib/notebook/browser/models/notebookInput';
|
import { NotebookInput } from 'sql/workbench/contrib/notebook/browser/models/notebookInput';
|
||||||
|
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||||
|
|
||||||
|
|
||||||
export const NOTEBOOK_SELECTOR: string = 'notebook-component';
|
export const NOTEBOOK_SELECTOR: string = 'notebook-component';
|
||||||
@@ -102,7 +103,8 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
|||||||
@Inject(ICapabilitiesService) private capabilitiesService: ICapabilitiesService,
|
@Inject(ICapabilitiesService) private capabilitiesService: ICapabilitiesService,
|
||||||
@Inject(ITextFileService) private textFileService: ITextFileService,
|
@Inject(ITextFileService) private textFileService: ITextFileService,
|
||||||
@Inject(ILogService) private readonly logService: ILogService,
|
@Inject(ILogService) private readonly logService: ILogService,
|
||||||
@Inject(ITelemetryService) private telemetryService: ITelemetryService
|
@Inject(ITelemetryService) private telemetryService: ITelemetryService,
|
||||||
|
@Inject(ICommandService) private commandService: ICommandService
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
this.updateProfile();
|
this.updateProfile();
|
||||||
@@ -226,10 +228,10 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
|||||||
|
|
||||||
private setScrollPosition(): void {
|
private setScrollPosition(): void {
|
||||||
if (this._notebookParams && this._notebookParams.input) {
|
if (this._notebookParams && this._notebookParams.input) {
|
||||||
this._notebookParams.input.layoutChanged(() => {
|
this._register(this._notebookParams.input.layoutChanged(() => {
|
||||||
let containerElement = <HTMLElement>this.container.nativeElement;
|
let containerElement = <HTMLElement>this.container.nativeElement;
|
||||||
containerElement.scrollTop = this._scrollTop;
|
containerElement.scrollTop = this._scrollTop;
|
||||||
});
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,6 +439,8 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
|||||||
this._navProvider = this.notebookService.getNavigationProvider(this._notebookParams.notebookUri);
|
this._navProvider = this.notebookService.getNavigationProvider(this._notebookParams.notebookUri);
|
||||||
|
|
||||||
if (this.contextKeyService.getContextKeyValue('bookOpened') && this._navProvider) {
|
if (this.contextKeyService.getContextKeyValue('bookOpened') && this._navProvider) {
|
||||||
|
// If there's a book opened but the current notebook isn't part of the book, this is a no-op
|
||||||
|
this.commandService.executeCommand('notebook.command.revealInBooksViewlet', this._notebookParams.notebookUri, false);
|
||||||
this._navProvider.getNavigation(this._notebookParams.notebookUri).then(result => {
|
this._navProvider.getNavigation(this._notebookParams.notebookUri).then(result => {
|
||||||
this.navigationResult = result;
|
this.navigationResult = result;
|
||||||
this.addButton(localize('previousButtonLabel', "< Previous"),
|
this.addButton(localize('previousButtonLabel', "< Previous"),
|
||||||
|
|||||||
Reference in New Issue
Block a user