Skip to content

Commit

Permalink
Merge branch 'release/v3.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed Mar 14, 2023
2 parents f2a4697 + fdefe54 commit 00dc225
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 115 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Release Notes

## 3.1.0 (2023-03-13)

* Add support for the ``${command:platformio-ide.activeEnvironment}`` variable that can be used in a custom [PlatformIO Toolbar](https://docs.platformio.org/en/latest/integration/ide/vscode.html#platformio-toolbar) and [VSCode variable substitution](https://code.visualstudio.com/docs/editor/variables-reference) (issue [#3588](https://github.com/platformio/platformio-vscode-ide/issues/3588))
* Focus on the project configuration output tab only on error (issue [#3535](https://github.com/platformio/platformio-vscode-ide/issues/3535))
* Fixed an issue with a task runner on Windows 7 (issue [#3481](https://github.com/platformio/platformio-vscode-ide/issues/3481))
* Fixed "Select All", "Undo", and "Redo" operations on macOS for PIO Home (pull [#3451](https://github.com/platformio/platformio-vscode-ide/pull/3451))
* Fixed an issue when the "Upload & Monitor" task selects the wrong environment (issue [#2623](https://github.com/platformio/platformio-vscode-ide/issues/2623))

## 3.0.0 (2023-02-01)

**Requires PlatformIO Core 6.1.6 + VSCode 1.65 or above**
Expand Down
43 changes: 14 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "platformio-ide",
"version": "3.0.0",
"version": "3.1.0",
"publisher": "platformio",
"engines": {
"vscode": "^1.65.0"
Expand Down Expand Up @@ -36,16 +36,7 @@
"url": "https://github.com/platformio/platformio-vscode-ide.git"
},
"activationEvents": [
"workspaceContains:**/platformio.ini",
"onView:platformio-ide.quickAccess",
"onView:platformio-ide.projectTasks",
"onView:platformio-debug.peripherals",
"onView:platformio-debug.registers",
"onView:platformio-debug.memory",
"onView:platformio-debug.disassembly",
"onCommand:platformio-ide.showReleaseNotes",
"onCommand:platformio-ide.showHome",
"onCommand:platformio-ide.openPIOCoreCLI"
"workspaceContains:**/platformio.ini"
],
"contributes": {
"languages": [
Expand Down Expand Up @@ -129,8 +120,8 @@
"enablement": "pioCoreReady"
},
{
"command": "platformio-ide.switchProjectEnv",
"title": "Switch Project Environment",
"command": "platformio-ide.pickProjectEnv",
"title": "Pick Project Environment",
"category": "PlatformIO",
"icon": "$(root-folder)",
"enablement": "pioProjectReady"
Expand All @@ -151,21 +142,21 @@
},
{
"command": "platformio-ide.build",
"title": "Build",
"title": "Build active environment",
"category": "PlatformIO",
"icon": "$(check)",
"enablement": "pioProjectReady"
},
{
"command": "platformio-ide.upload",
"title": "Upload",
"title": "Upload active environment",
"category": "PlatformIO",
"icon": "$(arrow-right)",
"enablement": "pioProjectReady"
},
{
"command": "platformio-ide.clean",
"title": "Clean",
"title": "Clean active environment",
"category": "PlatformIO",
"icon": "$(trashcan)",
"enablement": "pioProjectReady"
Expand All @@ -184,12 +175,6 @@
"icon": "$(beaker)",
"enablement": "pioProjectReady"
},
{
"command": "platformio-ide.remoteUpload",
"title": "Remote Upload",
"category": "PlatformIO",
"enablement": "pioProjectReady"
},
{
"command": "platformio-ide.rebuildProjectIndex",
"title": "Rebuild IntelliSense Index",
Expand Down Expand Up @@ -442,7 +427,7 @@
],
"view/title": [
{
"command": "platformio-ide.switchProjectEnv",
"command": "platformio-ide.pickProjectEnv",
"when": "pioMultiEnvProject && view == platformio-ide.projectTasks",
"group": "navigation"
},
Expand Down Expand Up @@ -886,23 +871,23 @@
},
"dependencies": {
"fs-plus": "~3.1.1",
"platformio-node-helpers": "~9.9.1",
"platformio-node-helpers": "~10.0.0",
"platformio-vscode-debug": "~1.4.1"
},
"devDependencies": {
"@babel/core": "~7.20.12",
"@babel/core": "~7.21.0",
"@babel/eslint-parser": "~7.19.1",
"@babel/plugin-proposal-class-properties": "~7.18.6",
"@babel/preset-env": "~7.20.2",
"@types/node": "~14",
"@types/vscode": "~1.65.0",
"@vscode/vsce": "~2.17.0",
"@vscode/vsce": "~2.18.0",
"babel-loader": "~9.1.2",
"eslint": "~8.33.0",
"eslint": "~8.36.0",
"eslint-import-resolver-webpack": "~0.13.2",
"eslint-plugin-import": "~2.27.5",
"prettier": "~2.8.3",
"webpack": "~5.75.0",
"prettier": "~2.8.4",
"webpack": "~5.76.1",
"webpack-cli": "~5.0.1"
},
"extensionDependencies": [
Expand Down
2 changes: 1 addition & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
export const IS_WINDOWS = process.platform.startsWith('win');
export const IS_OSX = process.platform == 'darwin';
export const IS_LINUX = !IS_WINDOWS && !IS_OSX;
export const PIO_CORE_VERSION_SPEC = '>=6';
export const PIO_CORE_VERSION_SPEC = '>=6.1.6';
export const STATUS_BAR_PRIORITY_START = 10;
export const CONFLICTED_EXTENSION_IDS = [
'llvm-vs-code-extensions.vscode-clangd',
Expand Down
18 changes: 15 additions & 3 deletions src/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,23 @@ export default class PIOHome {
const iframeId = `pioHomeIFrame-${vscode.env.sessionId}`;
const iframeScript = `
<script>
for (const command of ['selectAll', 'copy', 'paste', 'cut', 'undo', 'redo']) {
function execCommand(data) {
document.getElementById('${iframeId}').contentWindow.postMessage({'command': 'execCommand', 'data': data}, '*');
}
for (const command of ['copy', 'paste', 'cut']) {
document.addEventListener(command, (e) => {
document.getElementById('${iframeId}').contentWindow.postMessage({'command': 'execCommand', 'data': command}, '*');
execCommand(command);
});
}
document.addEventListener('selectstart', (e) => {
execCommand('selectAll');
e.preventDefault();
});
window.addEventListener('keydown', (e) => {
if (e.key === 'z' && e.metaKey) {
execCommand(e.shiftKey ? 'redo' : 'undo');
}
});
window.addEventListener('message', (e) => {
if (e.data.command === 'kbd-event') {
window.dispatchEvent(new KeyboardEvent('keydown', e.data.data));
Expand Down Expand Up @@ -172,7 +184,7 @@ export default class PIOHome {

onOpenProjectCommand(params) {
if (extension.ProjectManager) {
updateProjectItemState(vscode.Uri.file(params).fsPath, 'activeEnv', undefined);
updateProjectItemState(vscode.Uri.file(params).fsPath, 'selectedEnv', undefined);
extension.ProjectManager.switchToProject(vscode.Uri.file(params).fsPath);
}
this.disposePanel();
Expand Down
44 changes: 24 additions & 20 deletions src/project/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ export default class ProjectManager {
vscode.commands.registerCommand('platformio-ide._runProjectTask', (task) =>
this._taskManager.runTask(task)
),
vscode.commands.registerCommand(
'platformio-ide.activeEnvironment',
async () => await this._pool.getActiveObserver().revealActiveEnvironment()
),
];
this.internalSubscriptions = [];

Expand Down Expand Up @@ -153,8 +157,8 @@ export default class ProjectManager {
}
projectHelpers.updateProjectItemState(
observer.projectDir,
'activeEnv',
observer.getActiveEnvName()
'selectedEnv',
observer.getSelectedEnv()
);
}

Expand All @@ -166,28 +170,28 @@ export default class ProjectManager {
this._sbEnvSwitcher.text = '$(root-folder) Loading...';

let currentProjectDir = undefined;
let currentEnvName = undefined;
let currentEnv = undefined;
if (this._pool.getActiveObserver()) {
currentProjectDir = this._pool.getActiveObserver().projectDir;
currentEnvName = this._pool.getActiveObserver().getActiveEnvName();
currentEnv = this._pool.getActiveObserver().getSelectedEnv();
}
const observer = this._pool.getObserver(projectDir);
if ('envName' in options) {
await observer.switchProjectEnv(options.envName);
} else if (!observer.getActiveEnvName()) {
if ('env' in options) {
await observer.switchProjectEnv(options.env);
} else if (!observer.getSelectedEnv()) {
await observer.switchProjectEnv(
projectHelpers.getProjectItemState(projectDir, 'activeEnv')
projectHelpers.getProjectItemState(projectDir, 'selectedEnv')
);
}

// ignore active project and & env
if (
!currentProjectDir ||
currentProjectDir !== projectDir ||
currentEnvName !== observer.getActiveEnvName()
currentEnv !== observer.getSelectedEnv()
) {
disposeSubscriptions(this.internalSubscriptions);
this._pool.switch(projectDir);
await this._pool.switch(projectDir);
this._taskManager = new ProjectTaskManager(projectDir, observer);
this.internalSubscriptions.push(
this._taskManager,
Expand Down Expand Up @@ -218,13 +222,13 @@ export default class ProjectManager {
);
this._sbEnvSwitcher.name = 'PlatformIO: Project Environment Switcher';
this._sbEnvSwitcher.tooltip = 'Switch PlatformIO Project Environment';
this._sbEnvSwitcher.command = 'platformio-ide.switchProjectEnv';
this._sbEnvSwitcher.command = 'platformio-ide.pickProjectEnv';
this._sbEnvSwitcher.text = '$(root-folder) Loading...';
this._sbEnvSwitcher.show();

this.subscriptions.push(
this._sbEnvSwitcher,
vscode.commands.registerCommand('platformio-ide.switchProjectEnv', () =>
vscode.commands.registerCommand('platformio-ide.pickProjectEnv', () =>
this.pickProjectEnv()
)
);
Expand All @@ -235,10 +239,10 @@ export default class ProjectManager {
if (!observer) {
return;
}
const envName = observer.getActiveEnvName()
? `env:${observer.getActiveEnvName()}`
const env = observer.getSelectedEnv()
? `env:${observer.getSelectedEnv()}`
: 'Default';
this._sbEnvSwitcher.text = `$(root-folder) ${envName} (${path.basename(
this._sbEnvSwitcher.text = `$(root-folder) ${env} (${path.basename(
observer.projectDir
)})`;
}
Expand All @@ -247,7 +251,7 @@ export default class ProjectManager {
const items = [];
for (const projectDir of projectHelpers.getPIOProjectDirs()) {
const observer = this._pool.getObserver(projectDir);
const envs = await observer.getProjectEnvs();
const envs = (await observer.getConfig()).envs();
if (!envs || !envs.length) {
continue;
}
Expand All @@ -260,10 +264,10 @@ export default class ProjectManager {
description: `$(folder) ${shortProjectDir} ("default_envs" from "platformio.ini")`,
});
items.push(
...envs.map((item) => ({
...envs.map((env) => ({
projectDir,
envName: item.name,
label: `env:${item.name}`,
env,
label: `env:${env}`,
description: `$(folder) ${shortProjectDir}`,
}))
);
Expand All @@ -274,6 +278,6 @@ export default class ProjectManager {
if (!pickedItem) {
return;
}
this.switchToProject(pickedItem.projectDir, { envName: pickedItem.envName });
this.switchToProject(pickedItem.projectDir, { env: pickedItem.env });
}
}
14 changes: 7 additions & 7 deletions src/project/task-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import * as vscode from 'vscode';
export default class ProjectTasksTreeProvider {
static DEFAULT_ENV_NAME = 'Default';

constructor(id, envs, tasks, activeEnvName) {
constructor(id, envs, tasks, selectedEnv = undefined) {
this.id = id;
this.envs = envs;
this.tasks = tasks;
this.activeEnvName = activeEnvName;
this.selectedEnv = selectedEnv;
this.multiEnvProject = this.envs.length > 1;
}

Expand Down Expand Up @@ -49,15 +49,15 @@ export default class ProjectTasksTreeProvider {

getRootChildren() {
const result = [];
for (const envName of [undefined, ...this.envs.map((item) => item.name)]) {
for (const env of [undefined, ...this.envs]) {
const treeItem = new vscode.TreeItem(
envName || ProjectTasksTreeProvider.DEFAULT_ENV_NAME,
envName && (envName === this.activeEnvName || !this.multiEnvProject)
env || ProjectTasksTreeProvider.DEFAULT_ENV_NAME,
env && (env === this.selectedEnv || !this.multiEnvProject)
? vscode.TreeItemCollapsibleState.Expanded
: vscode.TreeItemCollapsibleState.Collapsed
);
treeItem.id = `${this.id}-${envName}`;
treeItem.env = envName;
treeItem.id = `${this.id}-${env}`;
treeItem.env = env;
treeItem.iconPath = new vscode.ThemeIcon('root-folder');
result.push(treeItem);
}
Expand Down
Loading

0 comments on commit 00dc225

Please sign in to comment.