/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { CharCode } from '../../../base/common/charCode.js';67/**8* Returns:9* - -1 => the line consists of whitespace10* - otherwise => the indent level is returned value11*/12export function computeIndentLevel(line: string, tabSize: number): number {13let indent = 0;14let i = 0;15const len = line.length;1617while (i < len) {18const chCode = line.charCodeAt(i);19if (chCode === CharCode.Space) {20indent++;21} else if (chCode === CharCode.Tab) {22indent = indent - indent % tabSize + tabSize;23} else {24break;25}26i++;27}2829if (i === len) {30return -1; // line only consists of whitespace31}3233return indent;34}353637