Books: Ensure associatedResource is Present for Untitled Notebooks that have a File Associated with them (#9037)

* Conditionally add associatedResource t untitled nb

* Fix Jupyter Book notebook titles (#9039)

* Fix notebook titles

* Fix navigation links for books

* Added comments

Co-authored-by: Chris LaFreniere <40371649+chlafreniere@users.noreply.github.com>

* PR comment nit

Co-authored-by: Charles Gagnon <chgagnon@microsoft.com>
This commit is contained in:
Chris LaFreniere
2020-02-04 11:42:24 -08:00
committed by GitHub
parent 9c7f844d59
commit 2208666eef
3 changed files with 18 additions and 26 deletions

View File

@@ -67,7 +67,8 @@ export class BookTreeItem extends vscode.TreeItem {
private setCommand() {
if (this.book.type === BookTreeItemType.Notebook) {
let pathToNotebook = path.join(this.book.root, 'content', this._uri.concat('.ipynb'));
// The Notebook editor expects a posix path for the resource (it will still resolve to the correct fsPath based on OS)
const pathToNotebook = path.posix.join(this.book.root, 'content', this._uri.concat('.ipynb'));
this.command = { command: this.book.isUntitled ? 'bookTreeView.openUntitledNotebook' : 'bookTreeView.openNotebook', title: loc.openNotebookCommand, arguments: [pathToNotebook], };
} else if (this.book.type === BookTreeItemType.Markdown) {
let pathToMarkdown = path.join(this.book.root, 'content', this._uri.concat('.md'));
@@ -81,8 +82,8 @@ export class BookTreeItem extends vscode.TreeItem {
let i = --index;
while (i > -1) {
if (this.book.tableOfContents.sections[i].url) {
// TODO: Currently only navigating to notebooks. Need to add logic for markdown.
let pathToNotebook = path.join(this.book.root, 'content', this.book.tableOfContents.sections[i].url.concat('.ipynb'));
// The Notebook editor expects a posix path for the resource (it will still resolve to the correct fsPath based on OS)
let pathToNotebook = path.posix.join(this.book.root, 'content', this.book.tableOfContents.sections[i].url.concat('.ipynb'));
// eslint-disable-next-line no-sync
if (fs.existsSync(pathToNotebook)) {
this._previousUri = pathToNotebook;
@@ -97,8 +98,8 @@ export class BookTreeItem extends vscode.TreeItem {
let i = ++index;
while (i < this.book.tableOfContents.sections.length) {
if (this.book.tableOfContents.sections[i].url) {
// TODO: Currently only navigating to notebooks. Need to add logic for markdown.
let pathToNotebook = path.join(this.book.root, 'content', this.book.tableOfContents.sections[i].url.concat('.ipynb'));
// The Notebook editor expects a posix path for the resource (it will still resolve to the correct fsPath based on OS)
let pathToNotebook = path.posix.join(this.book.root, 'content', this.book.tableOfContents.sections[i].url.concat('.ipynb'));
// eslint-disable-next-line no-sync
if (fs.existsSync(pathToNotebook)) {
this._nextUri = pathToNotebook;