Skip to content

Commit 00dc225

Browse files
committed
Merge branch 'release/v3.1.0'
2 parents f2a4697 + fdefe54 commit 00dc225

8 files changed

+155
-115
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Release Notes
22

3+
## 3.1.0 (2023-03-13)
4+
5+
* 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))
6+
* Focus on the project configuration output tab only on error (issue [#3535](https://github.com/platformio/platformio-vscode-ide/issues/3535))
7+
* Fixed an issue with a task runner on Windows 7 (issue [#3481](https://github.com/platformio/platformio-vscode-ide/issues/3481))
8+
* Fixed "Select All", "Undo", and "Redo" operations on macOS for PIO Home (pull [#3451](https://github.com/platformio/platformio-vscode-ide/pull/3451))
9+
* Fixed an issue when the "Upload & Monitor" task selects the wrong environment (issue [#2623](https://github.com/platformio/platformio-vscode-ide/issues/2623))
10+
311
## 3.0.0 (2023-02-01)
412

513
**Requires PlatformIO Core 6.1.6 + VSCode 1.65 or above**

package.json

+14-29
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "platformio-ide",
3-
"version": "3.0.0",
3+
"version": "3.1.0",
44
"publisher": "platformio",
55
"engines": {
66
"vscode": "^1.65.0"
@@ -36,16 +36,7 @@
3636
"url": "https://github.com/platformio/platformio-vscode-ide.git"
3737
},
3838
"activationEvents": [
39-
"workspaceContains:**/platformio.ini",
40-
"onView:platformio-ide.quickAccess",
41-
"onView:platformio-ide.projectTasks",
42-
"onView:platformio-debug.peripherals",
43-
"onView:platformio-debug.registers",
44-
"onView:platformio-debug.memory",
45-
"onView:platformio-debug.disassembly",
46-
"onCommand:platformio-ide.showReleaseNotes",
47-
"onCommand:platformio-ide.showHome",
48-
"onCommand:platformio-ide.openPIOCoreCLI"
39+
"workspaceContains:**/platformio.ini"
4940
],
5041
"contributes": {
5142
"languages": [
@@ -129,8 +120,8 @@
129120
"enablement": "pioCoreReady"
130121
},
131122
{
132-
"command": "platformio-ide.switchProjectEnv",
133-
"title": "Switch Project Environment",
123+
"command": "platformio-ide.pickProjectEnv",
124+
"title": "Pick Project Environment",
134125
"category": "PlatformIO",
135126
"icon": "$(root-folder)",
136127
"enablement": "pioProjectReady"
@@ -151,21 +142,21 @@
151142
},
152143
{
153144
"command": "platformio-ide.build",
154-
"title": "Build",
145+
"title": "Build active environment",
155146
"category": "PlatformIO",
156147
"icon": "$(check)",
157148
"enablement": "pioProjectReady"
158149
},
159150
{
160151
"command": "platformio-ide.upload",
161-
"title": "Upload",
152+
"title": "Upload active environment",
162153
"category": "PlatformIO",
163154
"icon": "$(arrow-right)",
164155
"enablement": "pioProjectReady"
165156
},
166157
{
167158
"command": "platformio-ide.clean",
168-
"title": "Clean",
159+
"title": "Clean active environment",
169160
"category": "PlatformIO",
170161
"icon": "$(trashcan)",
171162
"enablement": "pioProjectReady"
@@ -184,12 +175,6 @@
184175
"icon": "$(beaker)",
185176
"enablement": "pioProjectReady"
186177
},
187-
{
188-
"command": "platformio-ide.remoteUpload",
189-
"title": "Remote Upload",
190-
"category": "PlatformIO",
191-
"enablement": "pioProjectReady"
192-
},
193178
{
194179
"command": "platformio-ide.rebuildProjectIndex",
195180
"title": "Rebuild IntelliSense Index",
@@ -442,7 +427,7 @@
442427
],
443428
"view/title": [
444429
{
445-
"command": "platformio-ide.switchProjectEnv",
430+
"command": "platformio-ide.pickProjectEnv",
446431
"when": "pioMultiEnvProject && view == platformio-ide.projectTasks",
447432
"group": "navigation"
448433
},
@@ -886,23 +871,23 @@
886871
},
887872
"dependencies": {
888873
"fs-plus": "~3.1.1",
889-
"platformio-node-helpers": "~9.9.1",
874+
"platformio-node-helpers": "~10.0.0",
890875
"platformio-vscode-debug": "~1.4.1"
891876
},
892877
"devDependencies": {
893-
"@babel/core": "~7.20.12",
878+
"@babel/core": "~7.21.0",
894879
"@babel/eslint-parser": "~7.19.1",
895880
"@babel/plugin-proposal-class-properties": "~7.18.6",
896881
"@babel/preset-env": "~7.20.2",
897882
"@types/node": "~14",
898883
"@types/vscode": "~1.65.0",
899-
"@vscode/vsce": "~2.17.0",
884+
"@vscode/vsce": "~2.18.0",
900885
"babel-loader": "~9.1.2",
901-
"eslint": "~8.33.0",
886+
"eslint": "~8.36.0",
902887
"eslint-import-resolver-webpack": "~0.13.2",
903888
"eslint-plugin-import": "~2.27.5",
904-
"prettier": "~2.8.3",
905-
"webpack": "~5.75.0",
889+
"prettier": "~2.8.4",
890+
"webpack": "~5.76.1",
906891
"webpack-cli": "~5.0.1"
907892
},
908893
"extensionDependencies": [

src/constants.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
export const IS_WINDOWS = process.platform.startsWith('win');
1010
export const IS_OSX = process.platform == 'darwin';
1111
export const IS_LINUX = !IS_WINDOWS && !IS_OSX;
12-
export const PIO_CORE_VERSION_SPEC = '>=6';
12+
export const PIO_CORE_VERSION_SPEC = '>=6.1.6';
1313
export const STATUS_BAR_PRIORITY_START = 10;
1414
export const CONFLICTED_EXTENSION_IDS = [
1515
'llvm-vs-code-extensions.vscode-clangd',

src/home.js

+15-3
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,23 @@ export default class PIOHome {
127127
const iframeId = `pioHomeIFrame-${vscode.env.sessionId}`;
128128
const iframeScript = `
129129
<script>
130-
for (const command of ['selectAll', 'copy', 'paste', 'cut', 'undo', 'redo']) {
130+
function execCommand(data) {
131+
document.getElementById('${iframeId}').contentWindow.postMessage({'command': 'execCommand', 'data': data}, '*');
132+
}
133+
for (const command of ['copy', 'paste', 'cut']) {
131134
document.addEventListener(command, (e) => {
132-
document.getElementById('${iframeId}').contentWindow.postMessage({'command': 'execCommand', 'data': command}, '*');
135+
execCommand(command);
133136
});
134137
}
138+
document.addEventListener('selectstart', (e) => {
139+
execCommand('selectAll');
140+
e.preventDefault();
141+
});
142+
window.addEventListener('keydown', (e) => {
143+
if (e.key === 'z' && e.metaKey) {
144+
execCommand(e.shiftKey ? 'redo' : 'undo');
145+
}
146+
});
135147
window.addEventListener('message', (e) => {
136148
if (e.data.command === 'kbd-event') {
137149
window.dispatchEvent(new KeyboardEvent('keydown', e.data.data));
@@ -172,7 +184,7 @@ export default class PIOHome {
172184

173185
onOpenProjectCommand(params) {
174186
if (extension.ProjectManager) {
175-
updateProjectItemState(vscode.Uri.file(params).fsPath, 'activeEnv', undefined);
187+
updateProjectItemState(vscode.Uri.file(params).fsPath, 'selectedEnv', undefined);
176188
extension.ProjectManager.switchToProject(vscode.Uri.file(params).fsPath);
177189
}
178190
this.disposePanel();

src/project/manager.js

+24-20
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ export default class ProjectManager {
102102
vscode.commands.registerCommand('platformio-ide._runProjectTask', (task) =>
103103
this._taskManager.runTask(task)
104104
),
105+
vscode.commands.registerCommand(
106+
'platformio-ide.activeEnvironment',
107+
async () => await this._pool.getActiveObserver().revealActiveEnvironment()
108+
),
105109
];
106110
this.internalSubscriptions = [];
107111

@@ -153,8 +157,8 @@ export default class ProjectManager {
153157
}
154158
projectHelpers.updateProjectItemState(
155159
observer.projectDir,
156-
'activeEnv',
157-
observer.getActiveEnvName()
160+
'selectedEnv',
161+
observer.getSelectedEnv()
158162
);
159163
}
160164

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

168172
let currentProjectDir = undefined;
169-
let currentEnvName = undefined;
173+
let currentEnv = undefined;
170174
if (this._pool.getActiveObserver()) {
171175
currentProjectDir = this._pool.getActiveObserver().projectDir;
172-
currentEnvName = this._pool.getActiveObserver().getActiveEnvName();
176+
currentEnv = this._pool.getActiveObserver().getSelectedEnv();
173177
}
174178
const observer = this._pool.getObserver(projectDir);
175-
if ('envName' in options) {
176-
await observer.switchProjectEnv(options.envName);
177-
} else if (!observer.getActiveEnvName()) {
179+
if ('env' in options) {
180+
await observer.switchProjectEnv(options.env);
181+
} else if (!observer.getSelectedEnv()) {
178182
await observer.switchProjectEnv(
179-
projectHelpers.getProjectItemState(projectDir, 'activeEnv')
183+
projectHelpers.getProjectItemState(projectDir, 'selectedEnv')
180184
);
181185
}
182186

183187
// ignore active project and & env
184188
if (
185189
!currentProjectDir ||
186190
currentProjectDir !== projectDir ||
187-
currentEnvName !== observer.getActiveEnvName()
191+
currentEnv !== observer.getSelectedEnv()
188192
) {
189193
disposeSubscriptions(this.internalSubscriptions);
190-
this._pool.switch(projectDir);
194+
await this._pool.switch(projectDir);
191195
this._taskManager = new ProjectTaskManager(projectDir, observer);
192196
this.internalSubscriptions.push(
193197
this._taskManager,
@@ -218,13 +222,13 @@ export default class ProjectManager {
218222
);
219223
this._sbEnvSwitcher.name = 'PlatformIO: Project Environment Switcher';
220224
this._sbEnvSwitcher.tooltip = 'Switch PlatformIO Project Environment';
221-
this._sbEnvSwitcher.command = 'platformio-ide.switchProjectEnv';
225+
this._sbEnvSwitcher.command = 'platformio-ide.pickProjectEnv';
222226
this._sbEnvSwitcher.text = '$(root-folder) Loading...';
223227
this._sbEnvSwitcher.show();
224228

225229
this.subscriptions.push(
226230
this._sbEnvSwitcher,
227-
vscode.commands.registerCommand('platformio-ide.switchProjectEnv', () =>
231+
vscode.commands.registerCommand('platformio-ide.pickProjectEnv', () =>
228232
this.pickProjectEnv()
229233
)
230234
);
@@ -235,10 +239,10 @@ export default class ProjectManager {
235239
if (!observer) {
236240
return;
237241
}
238-
const envName = observer.getActiveEnvName()
239-
? `env:${observer.getActiveEnvName()}`
242+
const env = observer.getSelectedEnv()
243+
? `env:${observer.getSelectedEnv()}`
240244
: 'Default';
241-
this._sbEnvSwitcher.text = `$(root-folder) ${envName} (${path.basename(
245+
this._sbEnvSwitcher.text = `$(root-folder) ${env} (${path.basename(
242246
observer.projectDir
243247
)})`;
244248
}
@@ -247,7 +251,7 @@ export default class ProjectManager {
247251
const items = [];
248252
for (const projectDir of projectHelpers.getPIOProjectDirs()) {
249253
const observer = this._pool.getObserver(projectDir);
250-
const envs = await observer.getProjectEnvs();
254+
const envs = (await observer.getConfig()).envs();
251255
if (!envs || !envs.length) {
252256
continue;
253257
}
@@ -260,10 +264,10 @@ export default class ProjectManager {
260264
description: `$(folder) ${shortProjectDir} ("default_envs" from "platformio.ini")`,
261265
});
262266
items.push(
263-
...envs.map((item) => ({
267+
...envs.map((env) => ({
264268
projectDir,
265-
envName: item.name,
266-
label: `env:${item.name}`,
269+
env,
270+
label: `env:${env}`,
267271
description: `$(folder) ${shortProjectDir}`,
268272
}))
269273
);
@@ -274,6 +278,6 @@ export default class ProjectManager {
274278
if (!pickedItem) {
275279
return;
276280
}
277-
this.switchToProject(pickedItem.projectDir, { envName: pickedItem.envName });
281+
this.switchToProject(pickedItem.projectDir, { env: pickedItem.env });
278282
}
279283
}

src/project/task-tree.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import * as vscode from 'vscode';
1111
export default class ProjectTasksTreeProvider {
1212
static DEFAULT_ENV_NAME = 'Default';
1313

14-
constructor(id, envs, tasks, activeEnvName) {
14+
constructor(id, envs, tasks, selectedEnv = undefined) {
1515
this.id = id;
1616
this.envs = envs;
1717
this.tasks = tasks;
18-
this.activeEnvName = activeEnvName;
18+
this.selectedEnv = selectedEnv;
1919
this.multiEnvProject = this.envs.length > 1;
2020
}
2121

@@ -49,15 +49,15 @@ export default class ProjectTasksTreeProvider {
4949

5050
getRootChildren() {
5151
const result = [];
52-
for (const envName of [undefined, ...this.envs.map((item) => item.name)]) {
52+
for (const env of [undefined, ...this.envs]) {
5353
const treeItem = new vscode.TreeItem(
54-
envName || ProjectTasksTreeProvider.DEFAULT_ENV_NAME,
55-
envName && (envName === this.activeEnvName || !this.multiEnvProject)
54+
env || ProjectTasksTreeProvider.DEFAULT_ENV_NAME,
55+
env && (env === this.selectedEnv || !this.multiEnvProject)
5656
? vscode.TreeItemCollapsibleState.Expanded
5757
: vscode.TreeItemCollapsibleState.Collapsed
5858
);
59-
treeItem.id = `${this.id}-${envName}`;
60-
treeItem.env = envName;
59+
treeItem.id = `${this.id}-${env}`;
60+
treeItem.env = env;
6161
treeItem.iconPath = new vscode.ThemeIcon('root-folder');
6262
result.push(treeItem);
6363
}

0 commit comments

Comments
 (0)