From fdc5814e665bb40a3f91ec398b4688daa191474a Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Tue, 21 Jul 2020 20:44:37 +0200 Subject: [PATCH] make sure the sketch file has the focus after the ws open. Signed-off-by: Akos Kitta --- .../src/browser/arduino-frontend-contribution.tsx | 3 +++ arduino-ide-extension/src/node/sketches-service-impl.ts | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx b/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx index bb926a04..2e3b72be 100644 --- a/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx +++ b/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx @@ -267,6 +267,9 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut for (const uri of uris) { await this.editorManager.open(new URI(uri)); } + if (uris.length) { + await this.editorManager.open(new URI(uris[0])); // Make sure the sketch file has the focus. + } } registerColors(colors: ColorRegistry): void { diff --git a/arduino-ide-extension/src/node/sketches-service-impl.ts b/arduino-ide-extension/src/node/sketches-service-impl.ts index ac6f6677..31ce5761 100644 --- a/arduino-ide-extension/src/node/sketches-service-impl.ts +++ b/arduino-ide-extension/src/node/sketches-service-impl.ts @@ -63,13 +63,19 @@ export class SketchesServiceImpl implements SketchesService, BackendApplicationC const fsPath = FileUri.fsPath(uri); if (fs.lstatSync(fsPath).isDirectory()) { if (await this.isSketchFolder(uri)) { + const basename = path.basename(fsPath) const fileNames = await fs.readdir(fsPath); for (const fileName of fileNames) { const filePath = path.join(fsPath, fileName); if (ALLOWED_FILE_EXTENSIONS.indexOf(path.extname(filePath)) !== -1 && fs.existsSync(filePath) && fs.lstatSync(filePath).isFile()) { - uris.push(FileUri.create(filePath).toString()) + const uri = FileUri.create(filePath).toString(); + if (fileName === basename + '.ino') { + uris.unshift(uri); + } else { + uris.push(uri); + } } } }