Skip to content

Commit fdc5814

Browse files
author
Akos Kitta
committed
make sure the sketch file has the focus after the ws open.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
1 parent 87b383f commit fdc5814

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
267267
for (const uri of uris) {
268268
await this.editorManager.open(new URI(uri));
269269
}
270+
if (uris.length) {
271+
await this.editorManager.open(new URI(uris[0])); // Make sure the sketch file has the focus.
272+
}
270273
}
271274

272275
registerColors(colors: ColorRegistry): void {

arduino-ide-extension/src/node/sketches-service-impl.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,19 @@ export class SketchesServiceImpl implements SketchesService, BackendApplicationC
6363
const fsPath = FileUri.fsPath(uri);
6464
if (fs.lstatSync(fsPath).isDirectory()) {
6565
if (await this.isSketchFolder(uri)) {
66+
const basename = path.basename(fsPath)
6667
const fileNames = await fs.readdir(fsPath);
6768
for (const fileName of fileNames) {
6869
const filePath = path.join(fsPath, fileName);
6970
if (ALLOWED_FILE_EXTENSIONS.indexOf(path.extname(filePath)) !== -1
7071
&& fs.existsSync(filePath)
7172
&& fs.lstatSync(filePath).isFile()) {
72-
uris.push(FileUri.create(filePath).toString())
73+
const uri = FileUri.create(filePath).toString();
74+
if (fileName === basename + '.ino') {
75+
uris.unshift(uri);
76+
} else {
77+
uris.push(uri);
78+
}
7379
}
7480
}
7581
}

0 commit comments

Comments
 (0)