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

add .pde support #793

Merged
merged 1 commit into from
Mar 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,8 @@
{
"id": "cpp",
"extensions": [
".ino"
".ino",
".pde"
]
}
],
Expand Down
25 changes: 25 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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 });
}

Expand Down
28 changes: 21 additions & 7 deletions src/views/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.