leading spaces alternative method

Added an alternative method for calculating the leading spaces instead of taking the index of the first non-whitespace character. Leaving it commented out, but still there as an alternative  in-case something goes wrong w/ the index method.
This commit is contained in:
tel0065 2022-03-23 21:42:05 -05:00 committed by GitHub
parent cfcbfd43fc
commit 6915cd5b44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -82,6 +82,7 @@ function getLeadingSpaces() {
} }
else { else {
let numSpaces = textLine.firstNonWhitespaceCharacterIndex; let numSpaces = textLine.firstNonWhitespaceCharacterIndex;
// let numSpaces = textLine.text.length - textLine.text.trimStart().length; // Alternative method, same result by calculating the leading spaces
vscode.window.showInformationMessage("Line Number " + lineNum.toString() + " Has " + numSpaces.toString()+ " Leading Spaces "); vscode.window.showInformationMessage("Line Number " + lineNum.toString() + " Has " + numSpaces.toString()+ " Leading Spaces ");
} }
} }