diff options
Diffstat (limited to 'extensions/html-language-features/server/src/modes/htmlFolding.ts')
-rw-r--r-- | extensions/html-language-features/server/src/modes/htmlFolding.ts | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/extensions/html-language-features/server/src/modes/htmlFolding.ts b/extensions/html-language-features/server/src/modes/htmlFolding.ts index 78674fb0bc4..38a84e5048a 100644 --- a/extensions/html-language-features/server/src/modes/htmlFolding.ts +++ b/extensions/html-language-features/server/src/modes/htmlFolding.ts @@ -7,16 +7,16 @@ import { TextDocument, FoldingRange, Position, Range, LanguageModes, LanguageMod import { CancellationToken } from 'vscode-languageserver'; export async function getFoldingRanges(languageModes: LanguageModes, document: TextDocument, maxRanges: number | undefined, _cancellationToken: CancellationToken | null): Promise<FoldingRange[]> { - let htmlMode = languageModes.getMode('html'); - let range = Range.create(Position.create(0, 0), Position.create(document.lineCount, 0)); + const htmlMode = languageModes.getMode('html'); + const range = Range.create(Position.create(0, 0), Position.create(document.lineCount, 0)); let result: FoldingRange[] = []; if (htmlMode && htmlMode.getFoldingRanges) { result.push(... await htmlMode.getFoldingRanges(document)); } // cache folding ranges per mode - let rangesPerMode: { [mode: string]: FoldingRange[] } = Object.create(null); - let getRangesForMode = async (mode: LanguageMode) => { + const rangesPerMode: { [mode: string]: FoldingRange[] } = Object.create(null); + const getRangesForMode = async (mode: LanguageMode) => { if (mode.getFoldingRanges) { let ranges = rangesPerMode[mode.getId()]; if (!Array.isArray(ranges)) { @@ -28,9 +28,9 @@ export async function getFoldingRanges(languageModes: LanguageModes, document: T return []; }; - let modeRanges = languageModes.getModesInRange(document, range); - for (let modeRange of modeRanges) { - let mode = modeRange.mode; + const modeRanges = languageModes.getModesInRange(document, range); + for (const modeRange of modeRanges) { + const mode = modeRange.mode; if (mode && mode !== htmlMode && !modeRange.attributeValue) { const ranges = await getRangesForMode(mode); result.push(...ranges.filter(r => r.startLine >= modeRange.start.line && r.endLine < modeRange.end.line)); @@ -54,11 +54,11 @@ function limitRanges(ranges: FoldingRange[], maxRanges: number) { // compute each range's nesting level in 'nestingLevels'. // count the number of ranges for each level in 'nestingLevelCounts' let top: FoldingRange | undefined = undefined; - let previous: FoldingRange[] = []; - let nestingLevels: number[] = []; - let nestingLevelCounts: number[] = []; + const previous: FoldingRange[] = []; + const nestingLevels: number[] = []; + const nestingLevelCounts: number[] = []; - let setNestingLevel = (index: number, level: number) => { + const setNestingLevel = (index: number, level: number) => { nestingLevels[index] = level; if (level < 30) { nestingLevelCounts[level] = (nestingLevelCounts[level] || 0) + 1; @@ -67,7 +67,7 @@ function limitRanges(ranges: FoldingRange[], maxRanges: number) { // compute nesting levels and sanitize for (let i = 0; i < ranges.length; i++) { - let entry = ranges[i]; + const entry = ranges[i]; if (!top) { top = entry; setNestingLevel(i, 0); @@ -93,7 +93,7 @@ function limitRanges(ranges: FoldingRange[], maxRanges: number) { let entries = 0; let maxLevel = 0; for (let i = 0; i < nestingLevelCounts.length; i++) { - let n = nestingLevelCounts[i]; + const n = nestingLevelCounts[i]; if (n) { if (n + entries > maxRanges) { maxLevel = i; @@ -102,9 +102,9 @@ function limitRanges(ranges: FoldingRange[], maxRanges: number) { entries += n; } } - let result = []; + const result = []; for (let i = 0; i < ranges.length; i++) { - let level = nestingLevels[i]; + const level = nestingLevels[i]; if (typeof level === 'number') { if (level < maxLevel || (level === maxLevel && entries++ < maxRanges)) { result.push(ranges[i]); |