diff --git a/src/sql/parts/notebook/notebook.contribution.ts b/src/sql/parts/notebook/notebook.contribution.ts index 8b681c0334..c7c1d64f02 100644 --- a/src/sql/parts/notebook/notebook.contribution.ts +++ b/src/sql/parts/notebook/notebook.contribution.ts @@ -18,7 +18,12 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti import { NotebookInput, NotebookInputModel, notebooksEnabledCondition } from 'sql/parts/notebook/notebookInput'; import { NotebookEditor } from 'sql/parts/notebook/notebookEditor'; import { CommandsRegistry } from 'vs/platform/commands/common/commands'; +import { INotebookProviderRegistry } from 'sql/services/notebook/notebookRegistry'; +const DEFAULT_NOTEBOOK_FILETYPE = 'IPYNB'; +const Extensions = { + NotebookProviderContribution: 'notebook.providers' +}; let counter = 0; @@ -44,6 +49,11 @@ export class NewNotebookAction extends Action { let title = `Untitled-${counter++}`; let untitledUri = URI.from({ scheme: Schemas.untitled, path: title }); let model = new NotebookInputModel(untitledUri, undefined, false, undefined); + if(!model.providerId) + { + let notebookRegistry = Registry.as(Extensions.NotebookProviderContribution); + model.providerId = notebookRegistry.getProviderForFileType(DEFAULT_NOTEBOOK_FILETYPE); + } let input = this._instantiationService.createInstance(NotebookInput, title, model); return this._editorService.openEditor(input, { pinned: true }).then(() => undefined); } diff --git a/src/sql/services/notebook/notebookServiceImpl.ts b/src/sql/services/notebook/notebookServiceImpl.ts index 61a26d8a66..d7c4e7ffd6 100644 --- a/src/sql/services/notebook/notebookServiceImpl.ts +++ b/src/sql/services/notebook/notebookServiceImpl.ts @@ -86,11 +86,17 @@ export class NotebookService implements INotebookService { // PRIVATE HELPERS ///////////////////////////////////////////////////// private doWithProvider(providerId: string, op: (provider: INotebookProvider) => Thenable): Thenable { // Make sure the provider exists before attempting to retrieve accounts - let provider = this._providers.get(providerId); + let provider: INotebookProvider; + if (this._providers.has(providerId)) { + provider = this._providers.get(providerId); + } + else { + provider = this._providers.get(DEFAULT_NOTEBOOK_PROVIDER); + } + if (!provider) { return Promise.reject(new Error(localize('notebookServiceNoProvider', 'Notebook provider does not exist'))).then(); } - return op(provider); }