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

ignoreAlignmentSpaces - an option to make this extension perfectly suit those who use tabs for indentation and spaces for alignment #143

Open
wants to merge 3 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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ Although you can use it as it is, there is the possibility to configure some asp

// The delay in ms until the editor gets updated.
"indentRainbow.updateDelay": 100 // 10 makes it super fast but may cost more resources

// Do not consider spaces after the last tab, or spaces without tabs, as part of the indent.
// This can be useful when using only tabs for indenting and only spaces for alignment.
"indentRainbow.ignoreAlignmentSpaces": true // false is the default
```

*Notice: Defining both `includedLanguages` and `excludedLanguages` does not make much sense. Use one of both!*
Expand Down
Binary file modified indent-rainbow-8.3.1.vsix
Binary file not shown.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@
"type": "number",
"default": 1,
"description": "This property defines the indent indicator lineWidth when using light mode."
},
"indentRainbow.ignoreAlignmentSpaces": {
"type": "boolean",
"default": false,
"description": "Ignore spaces after the last tab."
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export function activate(context: vscode.ExtensionContext) {
const colorOnWhiteSpaceOnly = vscode.workspace.getConfiguration('indentRainbow')['colorOnWhiteSpaceOnly'] || false;
const indicatorStyle = vscode.workspace.getConfiguration('indentRainbow')['indicatorStyle'] || 'classic';
const lightIndicatorStyleLineWidth = vscode.workspace.getConfiguration('indentRainbow')['lightIndicatorStyleLineWidth'] || 1;
const ignoreAlignmentSpaces = vscode.workspace.getConfiguration('indentRainbow')['ignoreAlignmentSpaces'] || false;

// Colors will cycle through, and can be any size that you want
const colors = vscode.workspace.getConfiguration('indentRainbow')['colors'] || [
Expand Down Expand Up @@ -162,7 +163,9 @@ export function activate(context: vscode.ExtensionContext) {
if (!activeEditor) {
return;
}
var regEx = /^[\t ]+/gm;

var regEx = ignoreAlignmentSpaces ? /^[\t ]*\t+/gm : /^[\t ]+/gm;

var text = activeEditor.document.getText();
var tabSizeRaw = activeEditor.options.tabSize;
var tabSize = 4
Expand Down