Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggle command #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export function activate(context: vscode.ExtensionContext) {

// Create a decorator types that we use to decorate indent levels
let decorationTypes = [];
let decorationTypesStore = [];

let doIt = false;
let clearMe = false;
Expand All @@ -26,18 +27,36 @@ export function activate(context: vscode.ExtensionContext) {
/.*\*.*/g
];

var active = false;
var colors = vscode.workspace.getConfiguration('indentRainbow')['colors'] || [
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this changed from const to var?

"rgba(64,64,16,0.3)",
"rgba(32,64,32,0.3)",
"rgba(64,32,64,0.3)",
"rgba(16,48,48,0.3)"
];

context.subscriptions.push(vscode.commands.registerCommand("indent-rainbow.toggle", async () => {
active = !active;
if(active === true)
{
decorationTypes = decorationTypesStore;
triggerUpdateDecorations();
}
else
{
decorationTypes.forEach((decorationType, index) => {
activeEditor.setDecorations(decorationType, []);
});
decorationTypes = [];
}
}));


// Colors will cycle through, and can be any size that you want
const colors = vscode.workspace.getConfiguration('indentRainbow')['colors'] || [
"rgba(64,64,16,0.3)",
"rgba(32,64,32,0.3)",
"rgba(64,32,64,0.3)",
"rgba(16,48,48,0.3)"
];

// Loops through colors and creates decoration types for each one
colors.forEach((color, index) => {
decorationTypes[index] = vscode.window.createTextEditorDecorationType({
decorationTypesStore[index] = vscode.window.createTextEditorDecorationType({
backgroundColor: color
});
});
Expand Down
Binary file not shown.
Loading