Add setting for collapsing/expanding books at root level (#11543)

* Add setting for max number of expanded books

* Remove extra commas

* Add setting for expanding/collapsing books at root level

* Change typo in name of setting

* Change default value to false
This commit is contained in:
Barbara Valdez
2020-07-31 14:44:45 -07:00
committed by GitHub
parent 1a68f17650
commit c52155b621
4 changed files with 15 additions and 1 deletions

View File

@@ -6,6 +6,7 @@
import * as vscode from 'vscode';
import * as yaml from 'js-yaml';
import { BookTreeItem, BookTreeItemType } from './bookTreeItem';
import * as constants from '../common/constants';
import * as path from 'path';
import * as fileServices from 'fs';
import * as fs from 'fs-extra';
@@ -102,6 +103,12 @@ export class BookModel {
if (this.isNotebook) {
return undefined;
}
let notebookConfig = vscode.workspace.getConfiguration(constants.notebookConfigKey);
let collapsedItems = notebookConfig[constants.collapseBookItems];
let collapsibleState = vscode.TreeItemCollapsibleState.Expanded;
if (collapsedItems) {
collapsibleState = vscode.TreeItemCollapsibleState.Collapsed;
}
if (this._tableOfContentsPath) {
let root: string = path.dirname(path.dirname(this._tableOfContentsPath));
@@ -117,7 +124,7 @@ export class BookModel {
tableOfContents: { sections: this.parseJupyterSections(tableOfContents) },
page: tableOfContents,
type: BookTreeItemType.Book,
treeItemCollapsibleState: vscode.TreeItemCollapsibleState.Expanded,
treeItemCollapsibleState: collapsibleState,
isUntitled: this.openAsUntitled,
},
{

View File

@@ -19,6 +19,7 @@ export const notebookConfigKey = 'notebook';
export const trustedBooksConfigKey = 'trustedBooks';
export const maxBookSearchDepth = 'maxBookSearchDepth';
export const remoteBookDownloadTimeout = 'remoteBookDownloadTimeout';
export const collapseBookItems = 'collapseBookItems';
export const winPlatform = 'win32';