mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
No kernel is shown when open a new notebook from command palette (#3374)
Fixes #3271. Ensure a provider is defined when opening through command palette
This commit is contained in:
@@ -18,7 +18,12 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
|||||||
import { NotebookInput, NotebookInputModel, notebooksEnabledCondition } from 'sql/parts/notebook/notebookInput';
|
import { NotebookInput, NotebookInputModel, notebooksEnabledCondition } from 'sql/parts/notebook/notebookInput';
|
||||||
import { NotebookEditor } from 'sql/parts/notebook/notebookEditor';
|
import { NotebookEditor } from 'sql/parts/notebook/notebookEditor';
|
||||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
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;
|
let counter = 0;
|
||||||
|
|
||||||
@@ -44,6 +49,11 @@ export class NewNotebookAction extends Action {
|
|||||||
let title = `Untitled-${counter++}`;
|
let title = `Untitled-${counter++}`;
|
||||||
let untitledUri = URI.from({ scheme: Schemas.untitled, path: title });
|
let untitledUri = URI.from({ scheme: Schemas.untitled, path: title });
|
||||||
let model = new NotebookInputModel(untitledUri, undefined, false, undefined);
|
let model = new NotebookInputModel(untitledUri, undefined, false, undefined);
|
||||||
|
if(!model.providerId)
|
||||||
|
{
|
||||||
|
let notebookRegistry = Registry.as<INotebookProviderRegistry>(Extensions.NotebookProviderContribution);
|
||||||
|
model.providerId = notebookRegistry.getProviderForFileType(DEFAULT_NOTEBOOK_FILETYPE);
|
||||||
|
}
|
||||||
let input = this._instantiationService.createInstance(NotebookInput, title, model);
|
let input = this._instantiationService.createInstance(NotebookInput, title, model);
|
||||||
return this._editorService.openEditor(input, { pinned: true }).then(() => undefined);
|
return this._editorService.openEditor(input, { pinned: true }).then(() => undefined);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,11 +86,17 @@ export class NotebookService implements INotebookService {
|
|||||||
// PRIVATE HELPERS /////////////////////////////////////////////////////
|
// PRIVATE HELPERS /////////////////////////////////////////////////////
|
||||||
private doWithProvider<T>(providerId: string, op: (provider: INotebookProvider) => Thenable<T>): Thenable<T> {
|
private doWithProvider<T>(providerId: string, op: (provider: INotebookProvider) => Thenable<T>): Thenable<T> {
|
||||||
// Make sure the provider exists before attempting to retrieve accounts
|
// 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) {
|
if (!provider) {
|
||||||
return Promise.reject(new Error(localize('notebookServiceNoProvider', 'Notebook provider does not exist'))).then();
|
return Promise.reject(new Error(localize('notebookServiceNoProvider', 'Notebook provider does not exist'))).then();
|
||||||
}
|
}
|
||||||
|
|
||||||
return op(provider);
|
return op(provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user