Skip to content

Commit

Permalink
feat: Turns IntelliSense on and off
Browse files Browse the repository at this point in the history
  • Loading branch information
ironcev committed Sep 27, 2017
1 parent fa654b0 commit a71d7fd
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 10 deletions.
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@
"Other"
],
"activationEvents": [
"onCommand:withoutGuns.gunsOff"
"onCommand:withoutGuns.gunsOff",
"onCommand:withoutGuns.gunsOn"
],
"main": "./out/src/extension",
"contributes": {
"commands": [{
"commands": [
{
"command": "withoutGuns.gunsOff",
"title": "Guns Off"
},
{
"command": "withoutGuns.gunsOn",
"title": "Guns On"
}]
},
"scripts": {
Expand Down
55 changes: 47 additions & 8 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,52 @@
'use strict';
'use strict';

import * as vscode from 'vscode';
import * as vscode from 'vscode';

export function activate(context: vscode.ExtensionContext) {
console.log('Congratulations, your extension "without-guns" is now active!');
export function activate(context: vscode.ExtensionContext) {
const intelliSenseSettings = new IntelliSenseSettings(vscode.workspace.getConfiguration())

let disposable = vscode.commands.registerCommand('withoutGuns.gunsOff', () => {
vscode.window.showInformationMessage('Your guns are turned off ;-)');
});
let gunsOff = vscode.commands.registerCommand('withoutGuns.gunsOff', () => {
vscode.window.showInformationMessage('Your guns are turned off ;-)');
intelliSenseSettings.removeIntelliSense();
});

context.subscriptions.push(disposable);
let gunsOn = vscode.commands.registerCommand('withoutGuns.gunsOn', () => {
vscode.window.showInformationMessage('Your guns are turned on.');
intelliSenseSettings.applyInitialSettings();
});

context.subscriptions.push(gunsOff);
context.subscriptions.push(gunsOn);
}

class IntelliSenseSettings {
private readonly configuration : vscode.WorkspaceConfiguration;

private readonly initialQuickSuggestions : boolean;
private readonly initialWordBasedSuggestions : boolean;
private readonly initialParameterHints : boolean;
private readonly initialsuggestOnTriggerCharacters : boolean;

constructor(configuration : vscode.WorkspaceConfiguration) {
this.configuration = configuration;

this.initialQuickSuggestions = configuration.get("editor.quickSuggestions");
this.initialWordBasedSuggestions = configuration.get("editor.wordBasedSuggestions");
this.initialParameterHints = configuration.get("editor.parameterHints");
this.initialsuggestOnTriggerCharacters = configuration.get("editor.suggestOnTriggerCharacters");
}

applyInitialSettings() {
this.configuration.update("editor.quickSuggestions", this.initialQuickSuggestions);
this.configuration.update("editor.wordBasedSuggestions", this.initialWordBasedSuggestions);
this.configuration.update("editor.parameterHints", this.initialParameterHints);
this.configuration.update("editor.suggestOnTriggerCharacters", this.initialsuggestOnTriggerCharacters);
}

removeIntelliSense() {
this.configuration.update("editor.quickSuggestions", false);
this.configuration.update("editor.wordBasedSuggestions", false);
this.configuration.update("editor.parameterHints", false);
this.configuration.update("editor.suggestOnTriggerCharacters", false);
}
}

0 comments on commit a71d7fd

Please sign in to comment.