@@ -152,6 +152,24 @@ export async function activate(context: vscode.ExtensionContext) {
152152 return { board : arduinoContextModule . default . boardManager . currentBoard . name } ;
153153 } ) ;
154154
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+
155173 const getChildArduinoSources = ( directory : string ) => {
156174 if ( ! directory ) {
157175 directory = vscode . workspace . rootPath ;
@@ -180,18 +198,13 @@ export async function activate(context: vscode.ExtensionContext) {
180198
181199 registerArduinoCommand ( "arduino.setSketchFile" , async ( ) => {
182200 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+ } ) ;
193206
194- if ( ! newSketchFileName ) {
207+ if ( ! newSketchFileName || newSketchFileName === sketchFileName ) {
195208 return ;
196209 }
197210
0 commit comments