Unique title for opened notebooks (#10673)

* removing debug log

* Ensure unique title for Nb launch

* pr feedback

* pr feedback

* pr fedback

* pr feedback
This commit is contained in:
Arvind Ranasaria
2020-06-02 15:21:34 -07:00
committed by GitHub
parent da41fda4bb
commit f7c3484438
3 changed files with 5 additions and 5 deletions

View File

@@ -79,7 +79,7 @@ export class NotebookService implements INotebookService {
* @param content the notebook content
*/
async launchNotebookWithContent(title: string, content: string): Promise<azdata.nb.NotebookEditor> {
const uri: vscode.Uri = vscode.Uri.parse(`untitled:${title}`);
const uri: vscode.Uri = vscode.Uri.parse(`untitled:${this.findNextUntitledEditorName(title)}`);
return await azdata.nb.showNotebookDocument(uri, {
connectionProfile: undefined,
preview: false,

View File

@@ -124,7 +124,8 @@ export class PlatformService implements IPlatformService {
}
isNotebookNameUsed(title: string): boolean {
return (azdata.nb.notebookDocuments.findIndex(doc => doc.isUntitled && doc.fileName === title) > -1);
return (azdata.nb.notebookDocuments.findIndex(doc => doc.isUntitled && doc.fileName === title) > -1)
&& (vscode.workspace.textDocuments.findIndex(doc => doc.isUntitled && doc.fileName === title) > -1);
}
async makeDirectory(path: string): Promise<void> {

View File

@@ -2,7 +2,6 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as path from 'path';
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import { INotebookService, Notebook } from '../../services/notebookService';
@@ -91,8 +90,8 @@ export class NotebookWizard extends WizardBase<NotebookWizard, NotebookWizardPag
this.notebookService.backgroundExecuteNotebook(this.wizardInfo.taskName, notebook, 'deploy', this.platformService, env);
} else {
Object.assign(process.env, env);
const title = path.basename(this.notebookService.getNotebookPath(this.wizardInfo.notebook));
await this.notebookService.launchNotebookWithContent(title, JSON.stringify(notebook, undefined, 4));
const notebookPath = this.notebookService.getNotebookPath(this.wizardInfo.notebook);
await this.notebookService.launchNotebookWithContent(notebookPath, JSON.stringify(notebook, undefined, 4));
}
} catch (error) {
vscode.window.showErrorMessage(error);