Books/fix relative links (#7083)

* fix to make relative links work on untitled notebooks

* changes to make the preb/next links to work

* show filename with extension
This commit is contained in:
Maddy
2019-09-10 09:43:00 -07:00
committed by GitHub
parent 4dda5ee549
commit ab8a9509b8
3 changed files with 20 additions and 12 deletions

View File

@@ -276,7 +276,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
notebooks.push(notebook);
this._allNotebooks.set(pathToNotebook, notebook);
if (this._openAsUntitled) {
this._allNotebooks.set(path.basename(pathToNotebook, '.ipynb'), notebook);
this._allNotebooks.set(path.basename(pathToNotebook), notebook);
}
} else if (fs.existsSync(pathToMarkdown)) {
let markdown = new BookTreeItem({
@@ -307,7 +307,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
}
getNavigation(uri: vscode.Uri): Thenable<azdata.nb.NavigationResult> {
let notebook = this._allNotebooks.get(uri.fsPath);
let notebook = uri.scheme !== 'untitled' ? this._allNotebooks.get(uri.fsPath) : this._allNotebooks.get(path.basename(uri.fsPath));
let result: azdata.nb.NavigationResult;
if (notebook) {
result = {
@@ -332,19 +332,25 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
public get tableOfContentPaths() {
return this._tableOfContentPaths;
}
getUntitledNotebookUri(resource: string): vscode.Uri {
let title = this.findNextUntitledFileName(resource);
let untitledFileName: vscode.Uri = vscode.Uri.parse(`untitled:${title}`);
if (!this._allNotebooks.get(untitledFileName.fsPath)) {
let untitledFileName: vscode.Uri;
if (process.platform.indexOf('win') > -1) {
let title = path.join(path.dirname(resource), this.findNextUntitledFileName(resource));
untitledFileName = vscode.Uri.parse(`untitled:${title}`);
}
else {
untitledFileName = vscode.Uri.parse(resource).with({ scheme: 'untitled' });
}
if (!this._allNotebooks.get(untitledFileName.fsPath) && !this._allNotebooks.get(path.basename(untitledFileName.fsPath))) {
let notebook = this._allNotebooks.get(resource);
this._allNotebooks.set(untitledFileName.fsPath, notebook);
this._allNotebooks.set(path.basename(untitledFileName.fsPath), notebook);
}
return untitledFileName;
}
findNextUntitledFileName(filePath: string): string {
const fileExtension = path.extname(filePath);
const baseName = path.basename(filePath, fileExtension);
const baseName = path.basename(filePath);
let idx = 0;
let title = `${baseName}`;
do {