mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Book/untitled file name updates (#8579)
* file-name has entire path as name, changes to address that * await promises
This commit is contained in:
@@ -211,8 +211,8 @@ export class BookModel implements azdata.nb.NavigationProvider {
|
|||||||
if (notebook) {
|
if (notebook) {
|
||||||
result = {
|
result = {
|
||||||
hasNavigation: true,
|
hasNavigation: true,
|
||||||
previous: notebook.previousUri ? this.openAsUntitled ? this.getPlatformSpecificUri(notebook.previousUri) : vscode.Uri.file(notebook.previousUri) : undefined,
|
previous: notebook.previousUri ? this.openAsUntitled ? this.getUntitledUri(notebook.previousUri) : vscode.Uri.file(notebook.previousUri) : undefined,
|
||||||
next: notebook.nextUri ? this.openAsUntitled ? this.getPlatformSpecificUri(notebook.nextUri) : vscode.Uri.file(notebook.nextUri) : undefined
|
next: notebook.nextUri ? this.openAsUntitled ? this.getUntitledUri(notebook.nextUri) : vscode.Uri.file(notebook.nextUri) : undefined
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
result = {
|
result = {
|
||||||
@@ -224,12 +224,7 @@ export class BookModel implements azdata.nb.NavigationProvider {
|
|||||||
return Promise.resolve(result);
|
return Promise.resolve(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
getPlatformSpecificUri(resource: string): vscode.Uri {
|
getUntitledUri(resource: string): vscode.Uri {
|
||||||
if (process.platform === 'win32') {
|
return vscode.Uri.parse(`untitled:${resource}`);
|
||||||
return vscode.Uri.parse(`untitled:${resource}`);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return vscode.Uri.parse(resource).with({ scheme: 'untitled' });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -290,13 +290,8 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
|||||||
|
|
||||||
getUntitledNotebookUri(resource: string): vscode.Uri {
|
getUntitledNotebookUri(resource: string): vscode.Uri {
|
||||||
let untitledFileName: vscode.Uri;
|
let untitledFileName: vscode.Uri;
|
||||||
if (process.platform === 'win32') {
|
let nextTitle: string = this.findNextUntitledFileName(resource);
|
||||||
let title = path.join(path.dirname(resource), this.findNextUntitledFileName(resource));
|
untitledFileName = vscode.Uri.parse(`untitled:${nextTitle}`);
|
||||||
untitledFileName = vscode.Uri.parse(`untitled:${title}`);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
untitledFileName = vscode.Uri.parse(resource).with({ scheme: 'untitled' });
|
|
||||||
}
|
|
||||||
if (!this.currentBook.getAllBooks().get(untitledFileName.fsPath) && !this.currentBook.getAllBooks().get(path.basename(untitledFileName.fsPath))) {
|
if (!this.currentBook.getAllBooks().get(untitledFileName.fsPath) && !this.currentBook.getAllBooks().get(path.basename(untitledFileName.fsPath))) {
|
||||||
let notebook = this.currentBook.getAllBooks().get(resource);
|
let notebook = this.currentBook.getAllBooks().get(resource);
|
||||||
this.currentBook.getAllBooks().set(path.basename(untitledFileName.fsPath), notebook);
|
this.currentBook.getAllBooks().set(path.basename(untitledFileName.fsPath), notebook);
|
||||||
|
|||||||
@@ -720,7 +720,7 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements
|
|||||||
let result = await this._proxy.$getNavigation(handle, uri);
|
let result = await this._proxy.$getNavigation(handle, uri);
|
||||||
if (result) {
|
if (result) {
|
||||||
if (result.next.scheme === Schemas.untitled) {
|
if (result.next.scheme === Schemas.untitled) {
|
||||||
let untitledNbName: URI = URI.parse(`untitled:${result.next.path}`);
|
let untitledNbName: URI = URI.parse(`untitled:${path.basename(result.next.path)}`);
|
||||||
let content = await this._fileService.readFile(URI.file(result.next.path));
|
let content = await this._fileService.readFile(URI.file(result.next.path));
|
||||||
await this.doOpenEditor(untitledNbName, { initialContent: content.value.toString(), initialDirtyState: false });
|
await this.doOpenEditor(untitledNbName, { initialContent: content.value.toString(), initialDirtyState: false });
|
||||||
}
|
}
|
||||||
@@ -733,7 +733,7 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements
|
|||||||
let result = await this._proxy.$getNavigation(handle, uri);
|
let result = await this._proxy.$getNavigation(handle, uri);
|
||||||
if (result) {
|
if (result) {
|
||||||
if (result.previous.scheme === Schemas.untitled) {
|
if (result.previous.scheme === Schemas.untitled) {
|
||||||
let untitledNbName: URI = URI.parse(`untitled:${result.previous.path}`);
|
let untitledNbName: URI = URI.parse(`untitled:${path.basename(result.previous.path)}`);
|
||||||
let content = await this._fileService.readFile(URI.file(result.previous.path));
|
let content = await this._fileService.readFile(URI.file(result.previous.path));
|
||||||
await this.doOpenEditor(untitledNbName, { initialContent: content.value.toString(), initialDirtyState: false });
|
await this.doOpenEditor(untitledNbName, { initialContent: content.value.toString(), initialDirtyState: false });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user