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

Commit 71d6980

Browse files
authored
add .pde support (#793)
1 parent 3c97f84 commit 71d6980

File tree

4 files changed

+70
-16
lines changed

4 files changed

+70
-16
lines changed

package-lock.json

+22-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,8 @@
505505
{
506506
"id": "cpp",
507507
"extensions": [
508-
".ino"
508+
".ino",
509+
".pde"
509510
]
510511
}
511512
],

src/extension.ts

+25
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

4+
import * as fs from "fs";
45
import * as path from "path";
56
import * as Uuid from "uuid/v4";
67
import * as vscode from "vscode";
@@ -326,6 +327,30 @@ export async function activate(context: vscode.ExtensionContext) {
326327
vscode.commands.executeCommand("setContext", "vscode-arduino:showExampleExplorer", true);
327328
}
328329
});
330+
331+
vscode.workspace.onDidOpenTextDocument(async (document) => {
332+
if (/\.pde$/.test(document.uri.fsPath)) {
333+
const newFsName = document.uri.fsPath.replace(/\.pde$/, ".ino");
334+
await vscode.commands.executeCommand("workbench.action.closeActiveEditor");
335+
fs.renameSync(document.uri.fsPath, newFsName);
336+
await vscode.commands.executeCommand("vscode.open", vscode.Uri.file(newFsName));
337+
}
338+
});
339+
340+
vscode.window.onDidChangeActiveTextEditor(async (editor) => {
341+
if (!editor) {
342+
return;
343+
}
344+
345+
const document = editor.document;
346+
if (/\.pde$/.test(document.uri.fsPath)) {
347+
const newFsName = document.uri.fsPath.replace(/\.pde$/, ".ino");
348+
await vscode.commands.executeCommand("workbench.action.closeActiveEditor");
349+
fs.renameSync(document.uri.fsPath, newFsName);
350+
await vscode.commands.executeCommand("vscode.open", vscode.Uri.file(newFsName));
351+
}
352+
});
353+
329354
Logger.traceUserData("end-activate-extension", { correlationId: activeGuid });
330355
}
331356

src/views/package-lock.json

+21-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)