Skip to content

Commit 8ef67ef

Browse files
committed
Merge branch 'release/v2.4.0'
2 parents a5e2385 + 7b415f5 commit 8ef67ef

File tree

7 files changed

+120
-80
lines changed

7 files changed

+120
-80
lines changed

.babelrc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"plugins": [
3-
"transform-class-properties"
3+
"@babel/plugin-proposal-class-properties"
44
],
55
"presets": [
66
[
7-
"env",
7+
"@babel/preset-env",
88
{
99
"targets": {
10-
"node": "8"
10+
"node": "12"
1111
}
1212
}
1313
]

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = {
1313
'plugin:import/errors',
1414
'plugin:import/warnings'
1515
],
16-
'parser': 'babel-eslint',
16+
'parser': '@babel/eslint-parser',
1717
'parserOptions': {
1818
'ecmaVersion': 6,
1919
'sourceType': 'module'

CHANGELOG.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
# Release Notes
22

3+
## 2.4.0 (2021-11-05)
4+
5+
**Requires VSCode 1.57 or above**
6+
7+
- Added named status bars: "PlatformIO: Toolbar" and "PlatformIO: Project Environment Switcher" (ability to hide them separately) (issue [#2593](https://github.com/platformio/platformio-vscode-ide/issues/2593))
8+
- Added "Verbose Check" project task
9+
- Synchronize VSCode workspaces with PlatformIO Home Projects (requires PlatformIO Core 5.2.3 or above) (issue [#1367](https://github.com/platformio/platformio-vscode-ide/issues/1367))
10+
- Automatically switch to newly created project's environment (issue [#2414](https://github.com/platformio/platformio-vscode-ide/issues/2414))
11+
- Fixed an issue when "Copy to Clipboard" does not work in PlatformIO Home on macOS (requires PlatformIO Core 5.2.3 or above) (issue [#2570](https://github.com/platformio/platformio-vscode-ide/issues/2570))
12+
- PlatformIO IDE Installer
13+
* Updated installer script to 1.1.0
14+
* Check global PlatformIO Core installation when built-in is disabled
15+
* Handle "Could not find distutils module" error on Linux
16+
* Rebuild project IDE configuration on "platformio.ini" change
17+
318
## 2.3.4 (2021-10-19)
419

5-
- Start debugging without firmware uploading using a new ``loadMode`` launch option (see docs for [debug_load_mode](https://docs.platformio.org/en/latest/projectconf/section_env_debug.html#debug-load-mode) for more details). **Requires PlatformIO Core 5.2.2 or above**.
20+
- Start debugging without firmware uploading using a new ``loadMode`` launch option (see docs for [debug_load_mode](https://docs.platformio.org/en/latest/projectconf/section_env_debug.html#debug-load-mode) for more details).
621
- PlatformIO IDE Installer
722
* Ask the user to install Python manually if the portable version does not work
823
* Check compatible Python using the installer script

package.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "2.3.4",
44
"publisher": "platformio",
55
"engines": {
6-
"vscode": "^1.44.0"
6+
"vscode": "^1.57.0"
77
},
88
"license": "Apache-2.0",
99
"displayName": "PlatformIO IDE",
@@ -636,27 +636,27 @@
636636
"format": "prettier --single-quote --print-width 88 --write \"src/**/*.js\"",
637637
"vscode:package": "webpack --mode production && vsce package"
638638
},
639-
"devDependencies": {
640-
"@babel/core": "~7.15.8",
641-
"@types/node": "~12",
642-
"@types/vscode": "~1.44.0",
643-
"babel-eslint": "~10.1.0",
644-
"babel-loader": "~8.2.2",
645-
"babel-plugin-transform-class-properties": "~6.24.1",
646-
"babel-preset-env": "~1.7.0",
647-
"eslint": "~7.32.0",
648-
"eslint-import-resolver-webpack": "~0.13.1",
649-
"eslint-plugin-import": "~2.24.2",
650-
"prettier": "~2.3.2",
651-
"vsce": "~1.96.3",
652-
"webpack": "~5.50.0",
653-
"webpack-cli": "~4.7.2"
654-
},
655639
"dependencies": {
656640
"fs-plus": "~3.1.1",
657-
"platformio-node-helpers": "~9.2.4",
641+
"platformio-node-helpers": "~9.4.0",
658642
"platformio-vscode-debug": "~1.4.0"
659643
},
644+
"devDependencies": {
645+
"@babel/core": "~7.16.0",
646+
"@babel/eslint-parser": "~7.16.0",
647+
"@babel/plugin-proposal-class-properties": "~7.16.0",
648+
"@babel/preset-env": "~7.16.0",
649+
"@types/node": "~12",
650+
"@types/vscode": "~1.57.0",
651+
"babel-loader": "~8.2.3",
652+
"eslint": "~8.1.0",
653+
"eslint-import-resolver-webpack": "~0.13.2",
654+
"eslint-plugin-import": "~2.25.2",
655+
"prettier": "~2.4.1",
656+
"vsce": "~2.2.0",
657+
"webpack": "~5.61.0",
658+
"webpack-cli": "~4.9.1"
659+
},
660660
"extensionDependencies": [
661661
"ms-vscode.cpptools"
662662
]

src/home.js

Lines changed: 78 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import * as pioNodeHelpers from 'platformio-node-helpers';
1010

1111
import { IS_OSX } from './constants';
12+
import ProjectObservable from './project/observable';
13+
import crypto from 'crypto';
1214
import { extension } from './main';
1315
import { notifyError } from './utils';
1416
import path from 'path';
@@ -96,70 +98,37 @@ export default class PIOHome {
9698
await pioNodeHelpers.home.ensureServerStarted({
9799
port: extension.getSetting('pioHomeServerHttpPort'),
98100
host: extension.getSetting('pioHomeServerHttpHost'),
99-
onIDECommand: async (command, params) => {
100-
if (command === 'open_project') {
101-
if (extension.projectObservable) {
102-
extension.projectObservable.saveProjectStateItem(
103-
vscode.Uri.file(params).fsPath,
104-
'activeEnv',
105-
undefined
106-
);
107-
}
108-
this.disposePanel();
109-
if (vscode.workspace.workspaceFolders) {
110-
vscode.workspace.updateWorkspaceFolders(
111-
vscode.workspace.workspaceFolders.length,
112-
null,
113-
{ uri: vscode.Uri.file(params) }
114-
);
115-
} else {
116-
vscode.commands.executeCommand(
117-
'vscode.openFolder',
118-
vscode.Uri.file(params)
119-
);
120-
}
121-
vscode.commands.executeCommand('workbench.view.explorer');
122-
} else if (command === 'open_text_document') {
123-
const editor = await vscode.window.showTextDocument(
124-
vscode.Uri.file(params.path)
125-
);
126-
const gotoPosition = new vscode.Position(
127-
(params.line || 1) - 1,
128-
(params.column || 1) - 1
129-
);
130-
editor.selection = new vscode.Selection(gotoPosition, gotoPosition);
131-
editor.revealRange(
132-
new vscode.Range(gotoPosition, gotoPosition),
133-
vscode.TextEditorRevealType.InCenter
134-
);
135-
}
136-
},
101+
onIDECommand: await this.onIDECommand.bind(this),
137102
});
138103
const theme = this.getTheme();
104+
const iframeId =
105+
'pioHomeIFrame-' +
106+
crypto.createHash('sha1').update(crypto.randomBytes(512)).digest('hex');
107+
const iframeScript = `
108+
<script>
109+
for (const command of ['selectAll', 'copy', 'paste', 'cut', 'undo', 'redo']) {
110+
document.addEventListener(command, (e) => {
111+
document.getElementById('${iframeId}').contentWindow.postMessage({'command': 'execCommand', 'data': command}, '*');
112+
});
113+
}
114+
window.addEventListener('message', (e) => {
115+
if (e.data.command === 'kbd-event') {
116+
window.dispatchEvent(new KeyboardEvent('keydown', e.data.data));
117+
}
118+
});
119+
</script>
120+
`;
139121
return `<!DOCTYPE html>
140122
<html lang="en">
141-
<head>
142-
<script>
143-
window.addEventListener('message', (e) => {
144-
switch (e.data.command) {
145-
case 'kbd-event': {
146-
if (${IS_OSX}) {
147-
window.dispatchEvent(new KeyboardEvent('keydown', e.data.data));
148-
}
149-
break;
150-
}
151-
}
152-
}, false);
153-
</script>
154-
</head>
123+
<head>${IS_OSX ? iframeScript : ''}</head>
155124
<body style="margin: 0; padding: 0; height: 100%; overflow: hidden; background-color: ${
156125
theme === 'light' ? '#FFF' : '#1E1E1E'
157126
}">
158-
<iframe src="${pioNodeHelpers.home.getFrontendUrl({
159-
start: startUrl,
160-
theme,
161-
workspace: extension.getEnterpriseSetting('defaultPIOHomeWorkspace'),
162-
})}"
127+
<iframe id="${iframeId}" src="${pioNodeHelpers.home.getFrontendUrl({
128+
start: startUrl,
129+
theme,
130+
workspace: extension.getEnterpriseSetting('defaultPIOHomeWorkspace'),
131+
})}"
163132
width="100%"
164133
height="100%"
165134
frameborder="0"
@@ -169,6 +138,58 @@ export default class PIOHome {
169138
`;
170139
}
171140

141+
async onIDECommand(command, params) {
142+
switch (command) {
143+
case 'open_project':
144+
return this.onOpenProjectCommand(params);
145+
case 'open_text_document':
146+
return await this.onOpenTextDocumentCommand(params);
147+
case 'get_pio_project_dirs':
148+
return this.onGetPIOProjectDirs();
149+
}
150+
}
151+
152+
onOpenProjectCommand(params) {
153+
if (extension.projectObservable) {
154+
extension.projectObservable.saveProjectStateItem(
155+
vscode.Uri.file(params).fsPath,
156+
'activeEnv',
157+
undefined
158+
);
159+
extension.projectObservable.switchToProject(vscode.Uri.file(params).fsPath);
160+
}
161+
this.disposePanel();
162+
if (vscode.workspace.workspaceFolders) {
163+
vscode.workspace.updateWorkspaceFolders(
164+
vscode.workspace.workspaceFolders.length,
165+
null,
166+
{ uri: vscode.Uri.file(params) }
167+
);
168+
} else {
169+
vscode.commands.executeCommand('vscode.openFolder', vscode.Uri.file(params));
170+
}
171+
vscode.commands.executeCommand('workbench.view.explorer');
172+
return true;
173+
}
174+
175+
async onOpenTextDocumentCommand(params) {
176+
const editor = await vscode.window.showTextDocument(vscode.Uri.file(params.path));
177+
const gotoPosition = new vscode.Position(
178+
(params.line || 1) - 1,
179+
(params.column || 1) - 1
180+
);
181+
editor.selection = new vscode.Selection(gotoPosition, gotoPosition);
182+
editor.revealRange(
183+
new vscode.Range(gotoPosition, gotoPosition),
184+
vscode.TextEditorRevealType.InCenter
185+
);
186+
return true;
187+
}
188+
189+
onGetPIOProjectDirs() {
190+
return ProjectObservable.getPIOProjectDirs();
191+
}
192+
172193
onPanelDisposed() {
173194
this._currentPanel = undefined;
174195
}

src/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,11 @@ class PlatformIOVSCodeExtension {
295295
.forEach((item, index) => {
296296
const [text, tooltip, command] = item;
297297
const sbItem = vscode.window.createStatusBarItem(
298+
'pio-toolbar',
298299
vscode.StatusBarAlignment.Left,
299300
STATUS_BAR_PRIORITY_START + index + 1
300301
);
302+
sbItem.name = 'PlatformIO: Toolbar';
301303
sbItem.text = text;
302304
sbItem.tooltip = tooltip;
303305
sbItem.command = command;

src/project/observable.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,11 @@ export default class ProjectObservable {
253253

254254
registerEnvSwitcher() {
255255
this._sbEnvSwitcher = vscode.window.createStatusBarItem(
256+
'pio-env-switcher',
256257
vscode.StatusBarAlignment.Left,
257258
STATUS_BAR_PRIORITY_START
258259
);
260+
this._sbEnvSwitcher.name = 'PlatformIO: Project Environment Switcher';
259261
this._sbEnvSwitcher.tooltip = 'Switch PlatformIO Project Environment';
260262
this._sbEnvSwitcher.command = 'platformio-ide.switchProjectEnv';
261263
this._sbEnvSwitcher.text = '$(root-folder) Loading...';

0 commit comments

Comments
 (0)