From 524fbbdf4088b80b49e9fd7b2a283f8dabee8981 Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Fri, 4 Sep 2020 13:16:31 +0200 Subject: [PATCH] arduino/arduino-pro-ide#336: Fixed 'Save As...' Signed-off-by: Akos Kitta --- arduino-ide-extension/src/node/sketches-service-impl.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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) {