@@ -152,6 +152,24 @@ export async function activate(context: vscode.ExtensionContext) {
152
152
return { board : arduinoContextModule . default . boardManager . currentBoard . name } ;
153
153
} ) ;
154
154
155
+ registerArduinoCommand ( "set.current.sketch" , async ( ) => {
156
+ if ( ! status . compile ) {
157
+ status . compile = "upload" ;
158
+ try {
159
+ await vscode . window . withProgress ( {
160
+ location : vscode . ProgressLocation . Window ,
161
+ title : "Arduino: Uploading..." ,
162
+ } , async ( ) => {
163
+ await arduinoContextModule . default . arduinoApp . upload ( ) ;
164
+ } ) ;
165
+ } catch ( ex ) {
166
+ }
167
+ delete status . compile ;
168
+ }
169
+ } , ( ) => {
170
+ return { board : arduinoContextModule . default . boardManager . currentBoard . name } ;
171
+ } ) ;
172
+
155
173
const getChildArduinoSources = ( directory : string ) => {
156
174
if ( ! directory ) {
157
175
directory = vscode . workspace . rootPath ;
@@ -180,18 +198,13 @@ export async function activate(context: vscode.ExtensionContext) {
180
198
181
199
registerArduinoCommand ( "arduino.setSketchFile" , async ( ) => {
182
200
const sketchFileName = deviceContext . sketch ;
183
- const newSketchFileName = await vscode . window . showInputBox ( {
184
- placeHolder : sketchFileName ,
185
- validateInput : ( value ) => {
186
- if ( value && / \. ( ( i n o ) | ( c p p ) | c ) $ / . test ( value . trim ( ) ) ) {
187
- return null ;
188
- } else {
189
- return "Invalid sketch file name. Should be *.ino/*.cpp/*.c" ;
190
- }
191
- } ,
192
- } ) ;
201
+ let newSketchFileName = await vscode . window . showQuickPick (
202
+ getChildArduinoSources ( undefined ) ,
203
+ {
204
+ canPickMany : false , placeHolder : sketchFileName
205
+ } ) ;
193
206
194
- if ( ! newSketchFileName ) {
207
+ if ( ! newSketchFileName || newSketchFileName === sketchFileName ) {
195
208
return ;
196
209
}
197
210
0 commit comments