Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Commit b5f7361

Browse files
DotrarSneezry
authored andcommitted
Remove Processing Filetype (.PDE extension) (#868)
* Update package.json * Update extension.ts * config Changes * manual fix * additional space
1 parent 479c3c8 commit b5f7361

File tree

4 files changed

+41
-26
lines changed

4 files changed

+41
-26
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ This extension provides several commands in the Command Palette (<kbd>F1</kbd> o
6262
| `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. |
6363
| `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. |
6464
| `arduino.logLevel` | CLI output log level. Could be info or verbose. The default value is `"info"`. |
65+
| `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`. |
6566
| `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`|
6667
| `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). |
6768
| `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
7475
"arduino.path": "C:/Program Files (x86)/Arduino",
7576
"arduino.commandPath": "arduino_debug.exe",
7677
"arduino.logLevel": "info",
78+
"arduino.allowPDEFiletype": false,
7779
"arduino.enableUSBDetection": true,
7880
"arduino.disableTestingOpen": false,
7981
"arduino.skipHeaderProvider": false,

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,11 @@
465465
"verbose"
466466
]
467467
},
468+
"arduino.openPDEFiletype":{
469+
"type":"boolean",
470+
"default":false,
471+
"description": "Allow VSCode Arduino to open PDE sketches, from pre-1.0.0 versions of Arduino"
472+
},
468473
"arduino.enableUSBDetection": {
469474
"type": "boolean",
470475
"default": true
@@ -505,8 +510,7 @@
505510
{
506511
"id": "cpp",
507512
"extensions": [
508-
".ino",
509-
".pde"
513+
".ino"
510514
]
511515
}
512516
],

src/arduino/vscodeSettings.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ const configKeys = {
99
ADDITIONAL_URLS: "arduino.additionalUrls",
1010
LOG_LEVEL: "arduino.logLevel",
1111
AUTO_UPDATE_INDEX_FILES: "arduino.autoUpdateIndexFiles",
12-
ENABLE_USB_DETECTOIN: "arduino.enableUSBDetection",
12+
ALLOW_PDE_FILETYPE: "arduino.allowPDEFiletype",
13+
ENABLE_USB_DETECTION: "arduino.enableUSBDetection",
1314
DISABLE_TESTING_OPEN: "arduino.disableTestingOpen",
1415
IGNORE_BOARDS: "arduino.ignoreBoards",
1516
SKIP_HEADER_PROVIDER: "arduino.skipHeaderProvider",
@@ -21,6 +22,7 @@ export interface IVscodeSettings {
2122
commandPath: string;
2223
additionalUrls: string | string[];
2324
logLevel: string;
25+
allowPDEFiletype: boolean;
2426
enableUSBDetection: boolean;
2527
disableTestingOpen: boolean;
2628
ignoreBoards: string[];
@@ -57,8 +59,12 @@ export class VscodeSettings implements IVscodeSettings {
5759
return this.getConfigValue<string>(configKeys.LOG_LEVEL) || "info";
5860
}
5961

62+
public get allowPDEFiletype(): boolean {
63+
return this.getConfigValue<boolean>(configKeys.ALLOW_PDE_FILETYPE);
64+
}
65+
6066
public get enableUSBDetection(): boolean {
61-
return this.getConfigValue<boolean>(configKeys.ENABLE_USB_DETECTOIN);
67+
return this.getConfigValue<boolean>(configKeys.ENABLE_USB_DETECTION);
6268
}
6369

6470
public get disableTestingOpen(): boolean {

src/extension.ts

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as constants from "./common/constants";
99

1010
import { ArduinoContentProvider } from "./arduino/arduinoContentProvider";
1111
import { IBoard } from "./arduino/package";
12+
import { VscodeSettings } from "./arduino/vscodeSettings";
1213
import ArduinoActivator from "./arduinoActivator";
1314
import ArduinoContext from "./arduinoContext";
1415
import {
@@ -43,7 +44,7 @@ export async function activate(context: vscode.ExtensionContext) {
4344
"the arduino extension might not work appropriately.");
4445
}
4546
}
46-
47+
const vscodeSettings = VscodeSettings.getInstance();
4748
const deviceContext = DeviceContext.getInstance();
4849
deviceContext.extensionPath = context.extensionPath;
4950
context.subscriptions.push(deviceContext);
@@ -329,29 +330,31 @@ export async function activate(context: vscode.ExtensionContext) {
329330
}
330331
});
331332

332-
vscode.workspace.onDidOpenTextDocument(async (document) => {
333-
if (/\.pde$/.test(document.uri.fsPath)) {
334-
const newFsName = document.uri.fsPath.replace(/\.pde$/, ".ino");
335-
await vscode.commands.executeCommand("workbench.action.closeActiveEditor");
336-
fs.renameSync(document.uri.fsPath, newFsName);
337-
await vscode.commands.executeCommand("vscode.open", vscode.Uri.file(newFsName));
338-
}
339-
});
333+
const allowPDEFiletype = vscodeSettings.allowPDEFiletype;
340334

341-
vscode.window.onDidChangeActiveTextEditor(async (editor) => {
342-
if (!editor) {
343-
return;
344-
}
345-
346-
const document = editor.document;
347-
if (/\.pde$/.test(document.uri.fsPath)) {
348-
const newFsName = document.uri.fsPath.replace(/\.pde$/, ".ino");
349-
await vscode.commands.executeCommand("workbench.action.closeActiveEditor");
350-
fs.renameSync(document.uri.fsPath, newFsName);
351-
await vscode.commands.executeCommand("vscode.open", vscode.Uri.file(newFsName));
352-
}
353-
});
335+
if (allowPDEFiletype) {
336+
vscode.workspace.onDidOpenTextDocument(async (document) => {
337+
if (/\.pde$/.test(document.uri.fsPath)) {
338+
const newFsName = document.uri.fsPath.replace(/\.pde$/, ".ino");
339+
await vscode.commands.executeCommand("workbench.action.closeActiveEditor");
340+
fs.renameSync(document.uri.fsPath, newFsName);
341+
await vscode.commands.executeCommand("vscode.open", vscode.Uri.file(newFsName));
342+
}
343+
});
354344

345+
vscode.window.onDidChangeActiveTextEditor(async (editor) => {
346+
if (!editor) {
347+
return;
348+
}
349+
const document = editor.document;
350+
if (/\.pde$/.test(document.uri.fsPath)) {
351+
const newFsName = document.uri.fsPath.replace(/\.pde$/, ".ino");
352+
await vscode.commands.executeCommand("workbench.action.closeActiveEditor");
353+
fs.renameSync(document.uri.fsPath, newFsName);
354+
await vscode.commands.executeCommand("vscode.open", vscode.Uri.file(newFsName));
355+
}
356+
});
357+
}
355358
Logger.traceUserData("end-activate-extension", { correlationId: activeGuid });
356359
}
357360

0 commit comments

Comments
 (0)