diff --git a/CHANGELOG.md b/CHANGELOG.md index b195808..9867c63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Release Notes +## 1.4.6 (2018-11-23) + +* Warn about using .INO files that leads to the spurious problems with C/C++ IntelliSense service (issue [#400](https://github.com/platformio/platformio-vscode-ide/issues/400)) +* Use actual Python path when creating a virtual environment +* Shutdown all PIO Home servers when can't start a new one +* Better explanation about PIP issue on Windows + ## 1.4.5 (2018-11-18) * Reduced startup-time using extension bundling diff --git a/package.json b/package.json index f9ed620..4e380d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "platformio-ide", - "version": "1.4.5", + "version": "1.4.6", "publisher": "platformio", "engines": { "vscode": "^1.24.0" @@ -576,6 +576,7 @@ "devDependencies": { "@babel/core": "^7.1.6", "@types/node": "^8", + "babel-eslint": "^10.0.1", "babel-loader": "^8.0.4", "babel-plugin-transform-class-properties": "^6.24.1", "babel-preset-env": "^1.6.0", @@ -590,7 +591,7 @@ }, "dependencies": { "fs-plus": "^3.0.0", - "platformio-node-helpers": "^3.5.1", + "platformio-node-helpers": "^3.5.3", "platformio-vscode-debug": "^1.2.5" }, "extensionDependencies": [ diff --git a/src/installer/manager.js b/src/installer/manager.js index 1e6f374..989cda1 100644 --- a/src/installer/manager.js +++ b/src/installer/manager.js @@ -10,7 +10,7 @@ import * as pioNodeHelpers from 'platformio-node-helpers'; import { PIO_CORE_MIN_VERSION } from '../constants'; import PythonPrompt from './python-prompt'; -import StateStorage from './state-storage'; +import StateStorage from '../state-storage'; import vscode from 'vscode'; diff --git a/src/main.js b/src/main.js index a12ccee..19ec8cf 100644 --- a/src/main.js +++ b/src/main.js @@ -16,6 +16,7 @@ import PIOHome from './home'; import PIOTerminal from './terminal'; import ProjectTasksTreeProvider from './views/project-tasks-tree'; import QuickAccessTreeProvider from './views/quick-access-tree'; +import StateStorage from './state-storage'; import TaskManager from './tasks'; import path from 'path'; import vscode from 'vscode'; @@ -34,6 +35,7 @@ class PlatformIOVSCodeExtension { async activate(context) { this.context = context; + this.stateStorage = new StateStorage(context.globalState); this.pioHome = new PIOHome(); this.pioTerm = new PIOTerminal(); @@ -89,9 +91,13 @@ class PlatformIOVSCodeExtension { this.initToolbar({ ignoreCommands: this.getEnterpriseSetting('ignoreToolbarCommands') }); this.initProjectIndexer(); - await this.startPIOHome(); - misc.maybeRateExtension(this.context.globalState); + this.startPIOHome(); + + misc.maybeRateExtension(this.stateStorage); misc.warnAboutConflictedExtensions(); + this.subscriptions.push( + vscode.window.onDidChangeActiveTextEditor(editor => misc.warnAboutInoFile(editor, this.stateStorage)) + ); } getConfig() { diff --git a/src/misc.js b/src/misc.js index ca2cf98..f08754c 100644 --- a/src/misc.js +++ b/src/misc.js @@ -10,10 +10,10 @@ import { CONFLICTED_EXTENSION_IDS } from './constants'; import vscode from 'vscode'; -export async function maybeRateExtension(globalState) { - const momentoKey = 'rate-extension-state'; +export async function maybeRateExtension(stateStorage) { + const stateKey = 'rate-extension'; const askAfterSessionNums = 13; - let state = globalState.get(momentoKey); + let state = stateStorage.getValue(stateKey); if (state && state.done) { return; } @@ -26,7 +26,7 @@ export async function maybeRateExtension(globalState) { state.callCounter += 1; if (state.callCounter < askAfterSessionNums) { - globalState.update(momentoKey, state); + stateStorage.setValue(stateKey, state); return; } @@ -34,7 +34,7 @@ export async function maybeRateExtension(globalState) { 'If you enjoy using PlatformIO IDE for VSCode, would you mind taking a moment to rate it? ' + 'It will not take more than one minute. Thanks for your support!', { title: 'Rate PlatformIO IDE Extension', isCloseAffordance: false }, - { title: 'Remind me later', isCloseAffordance: false }, + { title: 'Remind later', isCloseAffordance: false }, { title: 'No, Thanks', isCloseAffordance: true } ); @@ -49,7 +49,7 @@ export async function maybeRateExtension(globalState) { default: state.callCounter = 0; } - globalState.update(momentoKey, state); + stateStorage.setValue(stateKey, state); } export async function warnAboutConflictedExtensions() { @@ -62,10 +62,10 @@ export async function warnAboutConflictedExtensions() { const selectedItem = await vscode.window.showWarningMessage( `Conflicted extensions with IntelliSense service were detected (${conflicted.join(', ')}). ` + 'Code-completion, linting and navigation will not work properly. ' + - 'Please disable or uninstall them.', + 'Please disable or uninstall them (Menu > View > Extensions).', { title: 'Show extensions', isCloseAffordance: false }, { title: 'More details', isCloseAffordance: false }, - { title: 'Remind me later', isCloseAffordance: true } + { title: 'Remind later', isCloseAffordance: true } ); switch (selectedItem ? selectedItem.title : undefined) { case 'More details': @@ -75,4 +75,34 @@ export async function warnAboutConflictedExtensions() { vscode.commands.executeCommand('workbench.extensions.action.showEnabledExtensions'); break; } +} + +export async function warnAboutInoFile(editor, stateStorage) { + if (!editor || !editor.document || !editor.document.fileName) { + return; + } + if (!editor.document.fileName.endsWith('.ino')) { + return; + } + const stateKey = 'ino-warn-disabled'; + if (stateStorage.getValue(stateKey)) { + return; + } + + const selectedItem = await vscode.window.showWarningMessage( + 'C/C++ IntelliSense service does not support .INO files. ' + + 'It might lead to the spurious problems with code completion, linting, and debugging. ' + + 'Please convert .INO sketch into the valid .CPP file.', + { title: 'Show instruction', isCloseAffordance: false }, + { title: 'Do not show again', isCloseAffordance: false }, + { title: 'Remind later', isCloseAffordance: true } + ); + switch (selectedItem ? selectedItem.title : undefined) { + case 'Show instruction': + vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('http://bit.ly/ino2cpp')); + break; + case 'Do not show again': + stateStorage.setValue(stateKey, 1); + break; + } } \ No newline at end of file diff --git a/src/installer/state-storage.js b/src/state-storage.js similarity index 93% rename from src/installer/state-storage.js rename to src/state-storage.js index 25db7d1..2faa8ba 100644 --- a/src/installer/state-storage.js +++ b/src/state-storage.js @@ -8,7 +8,7 @@ export default class StateStorage { - constructor(globalState, stateKey) { + constructor(globalState, stateKey='miscStates') { this._globalState = globalState; this._stateKey = stateKey; }