diff --git a/README.md b/README.md
index 6b93a8dc..f95d04f6 100644
--- a/README.md
+++ b/README.md
@@ -62,6 +62,7 @@ This extension provides several commands in the Command Palette (F1 o
| `arduino.commandPath` | Path to an executable (or script) relative to `arduino.path`. The default value is `arduino_debug.exe` for windows,`Contents/MacOS/Arduino` for Mac and `arduino` for Linux, You also can use a custom launch script to run Arduino by modifying this setting. (Requires a restart after change) Example: `run-arduino.bat` for Windows, `Contents/MacOS/run-arduino.sh` for Mac and `bin/run-arduino.sh` for Linux. |
| `arduino.additionalUrls` | Additional Boards Manager URLs for 3rd party packages. You can have multiple URLs in one string with a comma(`,`) as separator, or have a string array. The default value is empty. |
| `arduino.logLevel` | CLI output log level. Could be info or verbose. The default value is `"info"`. |
+| `arduino.allowPDEFiletype` | Allow the VSCode Arduino extension to open .pde files from pre-1.0.0 versions of Ardiuno. Note that this will break Processing code. Default value is `false`. |
| `arduino.enableUSBDetection` | Enable/disable USB detection from the VSCode Arduino extension. The default value is `true`. When your device is plugged in to your computer, it will pop up a message "`Detected board ****, Would you like to switch to this board type`". After clicking the `Yes` button, it will automatically detect which serial port (COM) is connected a USB device. If your device does not support this feature, please provide us with the PID/VID of your device; the code format is defined in `misc/usbmapping.json`.To learn more about how to list the vid/pid, use the following tools: https://github.com/EmergingTechnologyAdvisors/node-serialport `npm install -g serialport` `serialport-list -f jsonline`|
| `arduino.disableTestingOpen` | Enable/disable automatic sending of a test message to the serial port for checking the open status. The default value is `false` (a test message will be sent). |
| `arduino.skipHeaderProvider` | Enable/disable the extension providing completion items for headers. This functionality is included in newer versions of the C++ extension. The default value is `false`.|
@@ -74,6 +75,7 @@ The following Visual Studio Code settings are available for the Arduino extensio
"arduino.path": "C:/Program Files (x86)/Arduino",
"arduino.commandPath": "arduino_debug.exe",
"arduino.logLevel": "info",
+ "arduino.allowPDEFiletype": false,
"arduino.enableUSBDetection": true,
"arduino.disableTestingOpen": false,
"arduino.skipHeaderProvider": false,
diff --git a/package.json b/package.json
index 1ca05405..08c42db3 100644
--- a/package.json
+++ b/package.json
@@ -465,6 +465,11 @@
"verbose"
]
},
+ "arduino.openPDEFiletype":{
+ "type":"boolean",
+ "default":false,
+ "description": "Allow VSCode Arduino to open PDE sketches, from pre-1.0.0 versions of Arduino"
+ },
"arduino.enableUSBDetection": {
"type": "boolean",
"default": true
@@ -505,8 +510,7 @@
{
"id": "cpp",
"extensions": [
- ".ino",
- ".pde"
+ ".ino"
]
}
],
diff --git a/src/arduino/vscodeSettings.ts b/src/arduino/vscodeSettings.ts
index a2fce5ab..f66e268b 100644
--- a/src/arduino/vscodeSettings.ts
+++ b/src/arduino/vscodeSettings.ts
@@ -9,7 +9,8 @@ const configKeys = {
ADDITIONAL_URLS: "arduino.additionalUrls",
LOG_LEVEL: "arduino.logLevel",
AUTO_UPDATE_INDEX_FILES: "arduino.autoUpdateIndexFiles",
- ENABLE_USB_DETECTOIN: "arduino.enableUSBDetection",
+ ALLOW_PDE_FILETYPE: "arduino.allowPDEFiletype",
+ ENABLE_USB_DETECTION: "arduino.enableUSBDetection",
DISABLE_TESTING_OPEN: "arduino.disableTestingOpen",
IGNORE_BOARDS: "arduino.ignoreBoards",
SKIP_HEADER_PROVIDER: "arduino.skipHeaderProvider",
@@ -21,6 +22,7 @@ export interface IVscodeSettings {
commandPath: string;
additionalUrls: string | string[];
logLevel: string;
+ allowPDEFiletype: boolean;
enableUSBDetection: boolean;
disableTestingOpen: boolean;
ignoreBoards: string[];
@@ -57,8 +59,12 @@ export class VscodeSettings implements IVscodeSettings {
return this.getConfigValue(configKeys.LOG_LEVEL) || "info";
}
+ public get allowPDEFiletype(): boolean {
+ return this.getConfigValue(configKeys.ALLOW_PDE_FILETYPE);
+ }
+
public get enableUSBDetection(): boolean {
- return this.getConfigValue(configKeys.ENABLE_USB_DETECTOIN);
+ return this.getConfigValue(configKeys.ENABLE_USB_DETECTION);
}
public get disableTestingOpen(): boolean {
diff --git a/src/extension.ts b/src/extension.ts
index adf3ffb7..8347e873 100644
--- a/src/extension.ts
+++ b/src/extension.ts
@@ -9,6 +9,7 @@ import * as constants from "./common/constants";
import { ArduinoContentProvider } from "./arduino/arduinoContentProvider";
import { IBoard } from "./arduino/package";
+import { VscodeSettings } from "./arduino/vscodeSettings";
import ArduinoActivator from "./arduinoActivator";
import ArduinoContext from "./arduinoContext";
import {
@@ -43,7 +44,7 @@ export async function activate(context: vscode.ExtensionContext) {
"the arduino extension might not work appropriately.");
}
}
-
+ const vscodeSettings = VscodeSettings.getInstance();
const deviceContext = DeviceContext.getInstance();
deviceContext.extensionPath = context.extensionPath;
context.subscriptions.push(deviceContext);
@@ -329,29 +330,31 @@ export async function activate(context: vscode.ExtensionContext) {
}
});
- 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));
- }
- });
+ const allowPDEFiletype = vscodeSettings.allowPDEFiletype;
- 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));
- }
- });
+ if (allowPDEFiletype) {
+ 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 });
}