diff --git a/README.md b/README.md index 7be3105..95045c1 100644 --- a/README.md +++ b/README.md @@ -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!* diff --git a/indent-rainbow-8.3.1.vsix b/indent-rainbow-8.3.1.vsix index 84b9f4b..2f2321f 100644 Binary files a/indent-rainbow-8.3.1.vsix and b/indent-rainbow-8.3.1.vsix differ diff --git a/package.json b/package.json index f7f8a23..dfca55d 100644 --- a/package.json +++ b/package.json @@ -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." } } } diff --git a/src/extension.ts b/src/extension.ts index 147ae4e..6398011 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -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'] || [ @@ -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