diff --git a/arduino-ide-extension/src/node/sketches-service-impl.ts b/arduino-ide-extension/src/node/sketches-service-impl.ts index c33c623f..e97a39b1 100644 --- a/arduino-ide-extension/src/node/sketches-service-impl.ts +++ b/arduino-ide-extension/src/node/sketches-service-impl.ts @@ -382,7 +382,11 @@ void loop() { } const newName = path.basename(destination); try { - await fs.rename(path.join(destination, new URI(sketch.mainFileUri).path.base), path.join(destination, `${newName}.ino`)); + const oldPath = path.join(destination, new URI(sketch.mainFileUri).path.base); + const newPath = path.join(destination, `${newName}.ino`); + if (oldPath !== newPath) { + await fs.rename(oldPath, newPath); + } await this.loadSketch(destinationUri); // Sanity check. resolve(); } catch (e) {