Skip to content

Commit

Permalink
New option: Disable PlatformIO Toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed Aug 30, 2018
1 parent 1f1eb87 commit 7770415
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@
"properties": {
"task": {
"type": "string",
"description": "Task name"
"description": "PlatformIO Task ID"
}
}
}
Expand All @@ -481,7 +481,7 @@
"owner": "cpp",
"fileLocation": [
"relative",
"${workspaceRoot}"
"${workspaceFolder}"
],
"pattern": {
"regexp": "^([^:\\n]+):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
Expand Down Expand Up @@ -510,7 +510,7 @@
"platformio-ide.autoRebuildAutocompleteIndex": {
"type": "boolean",
"default": true,
"description": "Automatically rebuild C/C++ Project Index when platformio.ini is changed or when new libraries are installed."
"description": "Automatically rebuild Project IntelliSense Index when platformio.ini is changed or when new libraries are installed."
},
"platformio-ide.customPATH": {
"type": [
Expand Down Expand Up @@ -548,6 +548,11 @@
"type": "boolean",
"default": true,
"description": "Automatically close Serial Port Monitor before uploading/testing"
},
"platformio-ide.disableToolbar": {
"type": "boolean",
"default": false,
"description": "Disable PlatformIO Toolbar"
}
}
}
Expand Down
26 changes: 14 additions & 12 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,19 @@ class PlatformIOVSCodeExtension {
activate(context) {
this.context = context;
this.context.subscriptions.push(
vscode.workspace.onDidChangeWorkspaceFolders(this.init.bind(this))
vscode.workspace.onDidChangeWorkspaceFolders(this.reinit.bind(this)),
vscode.workspace.onDidChangeConfiguration(() => this.reinit(true))
);
this.init();
this.reinit();
}

async init() {
async reinit(force) {
const hasPIOProject = !!utils.getActivePIOProjectDir();
if (!hasPIOProject) {
if (!hasPIOProject || force) {
this.deactivate();
this._inited = false;
if (this.getConfig().get('activateOnlyOnPlatformIOProject')) {
return;
}
}
if (this._inited) {
if (this._inited || (!hasPIOProject && this.getConfig().get('activateOnlyOnPlatformIOProject'))) {
return;
}

Expand All @@ -78,7 +76,6 @@ class PlatformIOVSCodeExtension {
vscode.commands.executeCommand('setContext', 'pioCoreReady', true);

this.registerGlobalCommands();
this.initTasks();

this.subscriptions.push(
vscode.window.registerTreeDataProvider('platformio-activitybar.quickAccess',
Expand All @@ -87,15 +84,17 @@ class PlatformIOVSCodeExtension {

if (!hasPIOProject) {
await this.startPIOHome();
this.initStatusBar({ filterCommands: ['platformio-ide.showHome'] });
this.initToolbar({ filterCommands: ['platformio-ide.showHome'] });
return;
}

this.initTasks();

if (this.getConfig().get('updateTerminalPathConfiguration')) {
this.pioTerm.updateEnvConfiguration();
}

this.initStatusBar({ ignoreCommands: this.getEnterpriseSetting('ignoreToolbarCommands') });
this.initToolbar({ ignoreCommands: this.getEnterpriseSetting('ignoreToolbarCommands') });
this.initProjectIndexer();
await this.startPIOHome();
maybeRateExtension(this.context.globalState);
Expand Down Expand Up @@ -287,7 +286,10 @@ class PlatformIOVSCodeExtension {
piodebug.activate(this.context);
}

initStatusBar({ filterCommands, ignoreCommands }) {
initToolbar({ filterCommands, ignoreCommands }) {
if (this.getConfig().get('disableToolbar')) {
return;
}
[
['$(home)', 'PlatformIO: Home', 'platformio-ide.showHome'],
['$(check)', 'PlatformIO: Build', 'platformio-ide.build'],
Expand Down

0 comments on commit 7770415

Please sign in to comment.