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

Commit bbf9b1b

Browse files
committed
Use QuickPick to select source from list
It allows to select existing source file
1 parent b8745ac commit bbf9b1b

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

src/extension.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -180,23 +180,16 @@ 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+
let newSketchFileName = await vscode.window.showQuickPick(
184+
getChildArduinoSources(undefined),
185+
{
186+
canPickMany: false, placeHolder: sketchFileName
187+
});
193188

194-
if (!newSketchFileName) {
195-
return;
189+
if (newSketchFileName || newSketchFileName !== sketchFileName) {
190+
deviceContext.sketch = newSketchFileName;
191+
deviceContext.showStatusBar();
196192
}
197-
198-
deviceContext.sketch = newSketchFileName;
199-
deviceContext.showStatusBar();
200193
});
201194

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

0 commit comments

Comments
 (0)