mirror of
https://github.com/James-Yu/LaTeX-Workshop.git
synced 2024-10-04 15:17:59 +03:00
Fix section folding
This commit is contained in:
parent
0566b0e0f3
commit
3e1e21d9f4
@ -29,7 +29,9 @@ export class FoldingProvider implements vscode.FoldingRangeProvider {
|
||||
return sections.filter(section => section['level']).map((section, index, allSections) => {
|
||||
const startLine = section['lineNumber']
|
||||
let endLine
|
||||
if (index < allSections.length - 1) { // Not the last section
|
||||
|
||||
// Not the last section
|
||||
if (allSections.filter((element, elementIndex) => index < elementIndex && element['level'] <= section['level']).length > 0) {
|
||||
for (let siblingSectionIndex = index + 1; siblingSectionIndex < allSections.length; siblingSectionIndex++) {
|
||||
if (section['level'] >= allSections[siblingSectionIndex]['level']) {
|
||||
endLine = allSections[siblingSectionIndex]['lineNumber'] - 1
|
||||
@ -38,9 +40,10 @@ export class FoldingProvider implements vscode.FoldingRangeProvider {
|
||||
}
|
||||
} else {
|
||||
endLine = document.lineCount - 1
|
||||
for (; endLine > startLine; endLine--) {
|
||||
if (/\\end{document}/.test(document.lineAt(endLine).text)) {
|
||||
endLine--
|
||||
// Handle included files which don't contain \end{document}
|
||||
for (let endLineCopy = endLine; endLineCopy > startLine; endLineCopy--) {
|
||||
if (/\\end{document}/.test(document.lineAt(endLineCopy).text)) {
|
||||
endLine = endLineCopy--
|
||||
break
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user