@@ -12,6 +12,7 @@ import { IApplicationShell, ICommandManager } from '../../common/application/typ
12
12
import { IDisposable } from '../../common/types' ;
13
13
import { DataScience } from '../../common/utils/localize' ;
14
14
import { isUri } from '../../common/utils/misc' ;
15
+ import { PythonEnvironment } from '../../pythonEnvironments/info' ;
15
16
import { sendTelemetryEvent } from '../../telemetry' ;
16
17
import { Commands , Telemetry } from '../constants' ;
17
18
import { ExportManager } from '../export/exportManager' ;
@@ -33,15 +34,17 @@ export class ExportCommands implements IDisposable {
33
34
@inject ( IFileSystem ) private readonly fs : IFileSystem
34
35
) { }
35
36
public register ( ) {
36
- this . registerCommand ( Commands . ExportAsPythonScript , ( model ) => this . export ( model , ExportFormat . python ) ) ;
37
- this . registerCommand ( Commands . ExportToHTML , ( model , defaultFileName ?) =>
38
- this . export ( model , ExportFormat . html , defaultFileName )
37
+ this . registerCommand ( Commands . ExportAsPythonScript , ( model , interpreter ?) =>
38
+ this . export ( model , ExportFormat . python , undefined , interpreter )
39
39
) ;
40
- this . registerCommand ( Commands . ExportToPDF , ( model , defaultFileName ?) =>
41
- this . export ( model , ExportFormat . pdf , defaultFileName )
40
+ this . registerCommand ( Commands . ExportToHTML , ( model , defaultFileName ? , interpreter ?) =>
41
+ this . export ( model , ExportFormat . html , defaultFileName , interpreter )
42
42
) ;
43
- this . registerCommand ( Commands . Export , ( model , defaultFileName ?) =>
44
- this . export ( model , undefined , defaultFileName )
43
+ this . registerCommand ( Commands . ExportToPDF , ( model , defaultFileName ?, interpreter ?) =>
44
+ this . export ( model , ExportFormat . pdf , defaultFileName , interpreter )
45
+ ) ;
46
+ this . registerCommand ( Commands . Export , ( model , defaultFileName ?, interpreter ?) =>
47
+ this . export ( model , undefined , defaultFileName , interpreter )
45
48
) ;
46
49
}
47
50
@@ -58,7 +61,12 @@ export class ExportCommands implements IDisposable {
58
61
this . disposables . push ( disposable ) ;
59
62
}
60
63
61
- private async export ( modelOrUri : Uri | INotebookModel , exportMethod ?: ExportFormat , defaultFileName ?: string ) {
64
+ private async export (
65
+ modelOrUri : Uri | INotebookModel ,
66
+ exportMethod ?: ExportFormat ,
67
+ defaultFileName ?: string ,
68
+ interpreter ?: PythonEnvironment
69
+ ) {
62
70
defaultFileName = typeof defaultFileName === 'string' ? defaultFileName : undefined ;
63
71
let model : INotebookModel | undefined ;
64
72
if ( modelOrUri && isUri ( modelOrUri ) ) {
@@ -85,11 +93,13 @@ export class ExportCommands implements IDisposable {
85
93
}
86
94
87
95
if ( exportMethod ) {
88
- await this . exportManager . export ( exportMethod , model , defaultFileName ) ;
96
+ await this . exportManager . export ( exportMethod , model , defaultFileName , interpreter ) ;
89
97
} else {
90
98
// if we don't have an export method we need to ask for one and display the
91
99
// quickpick menu
92
- const pickedItem = await this . showExportQuickPickMenu ( model , defaultFileName ) . then ( ( item ) => item ) ;
100
+ const pickedItem = await this . showExportQuickPickMenu ( model , defaultFileName , interpreter ) . then (
101
+ ( item ) => item
102
+ ) ;
93
103
if ( pickedItem !== undefined ) {
94
104
pickedItem . handler ( ) ;
95
105
} else {
@@ -98,7 +108,11 @@ export class ExportCommands implements IDisposable {
98
108
}
99
109
}
100
110
101
- private getExportQuickPickItems ( model : INotebookModel , defaultFileName ?: string ) : IExportQuickPickItem [ ] {
111
+ private getExportQuickPickItems (
112
+ model : INotebookModel ,
113
+ defaultFileName ?: string ,
114
+ interpreter ?: PythonEnvironment
115
+ ) : IExportQuickPickItem [ ] {
102
116
return [
103
117
{
104
118
label : DataScience . exportPythonQuickPickLabel ( ) ,
@@ -107,7 +121,7 @@ export class ExportCommands implements IDisposable {
107
121
sendTelemetryEvent ( Telemetry . ClickedExportNotebookAsQuickPick , undefined , {
108
122
format : ExportFormat . python
109
123
} ) ;
110
- this . commandManager . executeCommand ( Commands . ExportAsPythonScript , model ) ;
124
+ this . commandManager . executeCommand ( Commands . ExportAsPythonScript , model , interpreter ) ;
111
125
}
112
126
} ,
113
127
{
@@ -117,7 +131,7 @@ export class ExportCommands implements IDisposable {
117
131
sendTelemetryEvent ( Telemetry . ClickedExportNotebookAsQuickPick , undefined , {
118
132
format : ExportFormat . html
119
133
} ) ;
120
- this . commandManager . executeCommand ( Commands . ExportToHTML , model , defaultFileName ) ;
134
+ this . commandManager . executeCommand ( Commands . ExportToHTML , model , defaultFileName , interpreter ) ;
121
135
}
122
136
} ,
123
137
{
@@ -127,17 +141,18 @@ export class ExportCommands implements IDisposable {
127
141
sendTelemetryEvent ( Telemetry . ClickedExportNotebookAsQuickPick , undefined , {
128
142
format : ExportFormat . pdf
129
143
} ) ;
130
- this . commandManager . executeCommand ( Commands . ExportToPDF , model , defaultFileName ) ;
144
+ this . commandManager . executeCommand ( Commands . ExportToPDF , model , defaultFileName , interpreter ) ;
131
145
}
132
146
}
133
147
] ;
134
148
}
135
149
136
150
private async showExportQuickPickMenu (
137
151
model : INotebookModel ,
138
- defaultFileName ?: string
152
+ defaultFileName ?: string ,
153
+ interpreter ?: PythonEnvironment
139
154
) : Promise < IExportQuickPickItem | undefined > {
140
- const items = this . getExportQuickPickItems ( model , defaultFileName ) ;
155
+ const items = this . getExportQuickPickItems ( model , defaultFileName , interpreter ) ;
141
156
142
157
const options : QuickPickOptions = {
143
158
ignoreFocusOut : false ,
0 commit comments