@@ -312,29 +312,14 @@ export class DeviceContext implements IDeviceContext, vscode.Disposable {
312
312
. then ( async ( fileUris ) => {
313
313
if ( fileUris . length === 0 ) {
314
314
let newSketchFileName = await vscode . window . showInputBox ( {
315
- value : "my- sketch.ino" ,
315
+ value : "sketch.ino" ,
316
316
prompt : "No sketch (*.ino) found in workspace, please provide a name" ,
317
317
placeHolder : "Sketch file name (*.ino or *.cpp)" ,
318
318
validateInput : ( value ) => {
319
- /* TODO (EW, 2020-02-18):
320
- * is 'c' actually allowed? Also found on within other files.
321
- * And the regular expression doesn't need the internal groups.
322
- * The outer group can be an anonymous group.
323
- * And \w doesn't match dashes - so any sketch containing dashes
324
- * will not be found.
325
- * The correct expression therefore would be something like this:
326
- *
327
- * /^[\w\-]+\.(?:ino|cpp)$/
328
- *
329
- * I'd recommend to define such regular expressions (including)
330
- * line splitting etc.) at the global constants file.
331
- * This is true for any hard coded paths (like the snippets below)
332
- * as well.
333
- */
334
- if ( value && / ^ \w + \. ( ( i n o ) | ( c p p ) | c ) $ / . test ( value . trim ( ) ) ) {
319
+ if ( value && / ^ [ \w - ] + \. (?: i n o | c p p ) $ / . test ( value . trim ( ) ) ) {
335
320
return null ;
336
321
} else {
337
- return "Invalid sketch file name. Should be *.ino/*.cpp/*.c " ;
322
+ return "Invalid sketch file name. Should be *.ino/*.cpp" ;
338
323
}
339
324
} ,
340
325
} ) ;
@@ -343,6 +328,8 @@ export class DeviceContext implements IDeviceContext, vscode.Disposable {
343
328
const snippets = fs . readFileSync ( path . join ( this . extensionPath , "snippets" , "sample.ino" ) ) ;
344
329
fs . writeFileSync ( path . join ( ArduinoWorkspace . rootPath , newSketchFileName ) , snippets ) ;
345
330
this . sketch = newSketchFileName ;
331
+ // Set a build directory in new configurations to avoid warnings about slow builds.
332
+ this . output = "build" ;
346
333
// Open the new sketch file.
347
334
const textDocument = await vscode . workspace . openTextDocument ( path . join ( ArduinoWorkspace . rootPath , newSketchFileName ) ) ;
348
335
vscode . window . showTextDocument ( textDocument , vscode . ViewColumn . One , true ) ;
0 commit comments