* Fix code folding bug.
This commit is contained in:
Sean McManus 2021-07-13 12:00:55 -07:00 коммит произвёл GitHub
Родитель 9c53c7090e
Коммит c98d437c0d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 4 добавлений и 10 удалений

Просмотреть файл

@ -27,19 +27,13 @@ export class FoldingRangeProvider implements vscode.FoldingRangeProvider {
return undefined;
}
const result: vscode.FoldingRange[] = [];
ranges.ranges.forEach((r: CppFoldingRange, index: number, array: CppFoldingRange[]) => {
let nextNonNestedIndex: number = index + 1; // Skip over nested if's.
for (; nextNonNestedIndex < array.length; ++nextNonNestedIndex) {
if (array[nextNonNestedIndex].range.start.line >= r.range.end.line) {
break;
}
}
ranges.ranges.forEach((r: CppFoldingRange) => {
const foldingRange: vscode.FoldingRange = {
start: r.range.start.line,
// Move the end range up one if it overlaps with the next start range, because
// Move the end range up one, so the end } line isn't folded, because
// VS Code doesn't support column-based folding: https://github.com/microsoft/vscode/issues/50840
end: r.range.end.line - (nextNonNestedIndex >= array.length ? 0 :
(array[nextNonNestedIndex].range.start.line !== r.range.end.line ? 0 : 1))
// The behavior matches TypeScript but not VS (which has column-based folding).
end: r.range.end.line - 1
};
switch (r.kind) {
case FoldingRangeKind.Comment: