mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-12 02:58:31 -05:00
Fix book provider load to not throw on startup (#8835)
* Fix book provider load to not throw on startup * Move tests to stable * Rename method * Fix floating promises and broken test
This commit is contained in:
@@ -41,28 +41,23 @@ export class BookModel implements azdata.nb.NavigationProvider {
|
||||
return this._allNotebooks;
|
||||
}
|
||||
|
||||
public async getTableOfContentFiles(workspacePath: string): Promise<void> {
|
||||
try {
|
||||
let notebookConfig = vscode.workspace.getConfiguration(notebookConfigKey);
|
||||
let maxDepth = notebookConfig[maxBookSearchDepth];
|
||||
// Use default value if user enters an invalid value
|
||||
if (isNullOrUndefined(maxDepth) || maxDepth < 0) {
|
||||
maxDepth = 5;
|
||||
} else if (maxDepth === 0) { // No limit of search depth if user enters 0
|
||||
maxDepth = undefined;
|
||||
}
|
||||
public async getTableOfContentFiles(folderPath: string): Promise<void> {
|
||||
let notebookConfig = vscode.workspace.getConfiguration(notebookConfigKey);
|
||||
let maxDepth = notebookConfig[maxBookSearchDepth];
|
||||
// Use default value if user enters an invalid value
|
||||
if (isNullOrUndefined(maxDepth) || maxDepth < 0) {
|
||||
maxDepth = 5;
|
||||
} else if (maxDepth === 0) { // No limit of search depth if user enters 0
|
||||
maxDepth = undefined;
|
||||
}
|
||||
|
||||
let p = path.join(workspacePath, '**', '_data', 'toc.yml').replace(/\\/g, '/');
|
||||
let tableOfContentPaths = await glob(p, { deep: maxDepth });
|
||||
if (tableOfContentPaths.length > 0) {
|
||||
this._tableOfContentPaths = this._tableOfContentPaths.concat(tableOfContentPaths);
|
||||
vscode.commands.executeCommand('setContext', 'bookOpened', true);
|
||||
} else {
|
||||
vscode.window.showErrorMessage(loc.errBookInitialize);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
let p = path.join(folderPath, '**', '_data', 'toc.yml').replace(/\\/g, '/');
|
||||
let tableOfContentPaths = await glob(p, { deep: maxDepth });
|
||||
if (tableOfContentPaths.length > 0) {
|
||||
this._tableOfContentPaths = this._tableOfContentPaths.concat(tableOfContentPaths);
|
||||
vscode.commands.executeCommand('setContext', 'bookOpened', true);
|
||||
} else {
|
||||
throw new Error(loc.missingTocError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user