@@ -10,7 +10,7 @@ import { IApplicationShell, ICommandManager } from '../../common/application/typ
10
10
import { IDisposable } from '../../common/types' ;
11
11
import { Commands } from '../constants' ;
12
12
import { ExportFormat , ExportManager , IExportManager } from '../export/exportManager' ;
13
- import { INotebookModel } from '../types' ;
13
+ import { INotebookEditorProvider , INotebookModel } from '../types' ;
14
14
15
15
interface IExportQuickPickItem extends QuickPickItem {
16
16
handler ( ) : void ;
@@ -22,7 +22,8 @@ export class ExportCommands implements IDisposable {
22
22
constructor (
23
23
@inject ( ICommandManager ) private readonly commandManager : ICommandManager ,
24
24
@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
26
27
) { }
27
28
public register ( ) {
28
29
this . registerCommand ( Commands . ExportAsPythonScript , ( model ) => this . export ( model , ExportFormat . python ) ) ;
@@ -46,8 +47,12 @@ export class ExportCommands implements IDisposable {
46
47
47
48
private async export ( model : INotebookModel , exportMethod ?: ExportFormat ) {
48
49
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 ;
51
56
}
52
57
53
58
if ( exportMethod ) {
0 commit comments