Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Commit a33ae43

Browse files
committed
Use QuickPick to select source from list
It allows to select existing source file
1 parent 25cb6ba commit a33ae43

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

src/extension.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -180,23 +180,17 @@ export async function activate(context: vscode.ExtensionContext) {
180180

181181
registerArduinoCommand("arduino.setSketchFile", async () => {
182182
const sketchFileName = deviceContext.sketch;
183-
const newSketchFileName = await vscode.window.showInputBox({
184-
placeHolder: sketchFileName,
185-
validateInput: (value) => {
186-
if (value && /\.((ino)|(cpp)|c)$/.test(value.trim())) {
187-
return null;
188-
} else {
189-
return "Invalid sketch file name. Should be *.ino/*.cpp/*.c";
190-
}
191-
},
192-
});
183+
const newSketchFileName = await vscode.window.showQuickPick(
184+
getChildArduinoSources(undefined),
185+
{
186+
canPickMany: false,
187+
placeHolder: sketchFileName,
188+
});
193189

194-
if (!newSketchFileName) {
195-
return;
190+
if (newSketchFileName || newSketchFileName !== sketchFileName) {
191+
deviceContext.sketch = newSketchFileName;
192+
deviceContext.showStatusBar();
196193
}
197-
198-
deviceContext.sketch = newSketchFileName;
199-
deviceContext.showStatusBar();
200194
});
201195

202196
registerArduinoCommand("arduino.uploadUsingProgrammer", async () => {

0 commit comments

Comments
 (0)