Skip to content

Commit 12ec207

Browse files
committed
fixed small bugs
1 parent 3e4f87a commit 12ec207

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/client/datascience/commands/exportCommands.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { IApplicationShell, ICommandManager } from '../../common/application/typ
1010
import { IDisposable } from '../../common/types';
1111
import { Commands } from '../constants';
1212
import { ExportFormat, ExportManager, IExportManager } from '../export/exportManager';
13-
import { INotebookModel } from '../types';
13+
import { INotebookEditorProvider, INotebookModel } from '../types';
1414

1515
interface IExportQuickPickItem extends QuickPickItem {
1616
handler(): void;
@@ -22,7 +22,8 @@ export class ExportCommands implements IDisposable {
2222
constructor(
2323
@inject(ICommandManager) private readonly commandManager: ICommandManager,
2424
@inject(IExportManager) private exportManager: ExportManager,
25-
@inject(IApplicationShell) private readonly applicationShell: IApplicationShell
25+
@inject(IApplicationShell) private readonly applicationShell: IApplicationShell,
26+
@inject(INotebookEditorProvider) private readonly notebookProvider: INotebookEditorProvider
2627
) {}
2728
public register() {
2829
this.registerCommand(Commands.ExportAsPythonScript, (model) => this.export(model, ExportFormat.python));
@@ -46,8 +47,12 @@ export class ExportCommands implements IDisposable {
4647

4748
private async export(model: INotebookModel, exportMethod?: ExportFormat) {
4849
if (!model) {
49-
// possibly show promp that you can't export if no model?
50-
return;
50+
// if no model then this was called from command pallete, need to get editor
51+
const activeEditor = this.notebookProvider.activeEditor;
52+
if (!activeEditor || !activeEditor.model) {
53+
return;
54+
}
55+
model = activeEditor.model;
5156
}
5257

5358
if (exportMethod) {

0 commit comments

Comments
 (0)