diff --git a/package-lock.json b/package-lock.json index 04be017c..c21d913b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "vscode-arduino", - "version": "0.2.24", + "version": "0.2.25", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -2706,12 +2706,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2726,17 +2728,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -2853,7 +2858,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -2865,6 +2871,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2879,6 +2886,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2886,12 +2894,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -2910,6 +2920,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -2990,7 +3001,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -3002,6 +3014,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -3123,6 +3136,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/package.json b/package.json index e5330266..6e29d561 100644 --- a/package.json +++ b/package.json @@ -505,7 +505,8 @@ { "id": "cpp", "extensions": [ - ".ino" + ".ino", + ".pde" ] } ], diff --git a/src/extension.ts b/src/extension.ts index c4c6fe52..30b59c5a 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +import * as fs from "fs"; import * as path from "path"; import * as Uuid from "uuid/v4"; import * as vscode from "vscode"; @@ -326,6 +327,30 @@ export async function activate(context: vscode.ExtensionContext) { vscode.commands.executeCommand("setContext", "vscode-arduino:showExampleExplorer", true); } }); + + vscode.workspace.onDidOpenTextDocument(async (document) => { + if (/\.pde$/.test(document.uri.fsPath)) { + const newFsName = document.uri.fsPath.replace(/\.pde$/, ".ino"); + await vscode.commands.executeCommand("workbench.action.closeActiveEditor"); + fs.renameSync(document.uri.fsPath, newFsName); + await vscode.commands.executeCommand("vscode.open", vscode.Uri.file(newFsName)); + } + }); + + vscode.window.onDidChangeActiveTextEditor(async (editor) => { + if (!editor) { + return; + } + + const document = editor.document; + if (/\.pde$/.test(document.uri.fsPath)) { + const newFsName = document.uri.fsPath.replace(/\.pde$/, ".ino"); + await vscode.commands.executeCommand("workbench.action.closeActiveEditor"); + fs.renameSync(document.uri.fsPath, newFsName); + await vscode.commands.executeCommand("vscode.open", vscode.Uri.file(newFsName)); + } + }); + Logger.traceUserData("end-activate-extension", { correlationId: activeGuid }); } diff --git a/src/views/package-lock.json b/src/views/package-lock.json index 75667bc9..d42dd7c8 100644 --- a/src/views/package-lock.json +++ b/src/views/package-lock.json @@ -1905,12 +1905,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -1925,17 +1927,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -2052,7 +2057,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -2064,6 +2070,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2078,6 +2085,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2085,12 +2093,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -2109,6 +2119,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -2189,7 +2200,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -2201,6 +2213,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -2322,6 +2335,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",