mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
Merge pull request #33146 from overleaf/copilot/fix-code-folding-bug
Fix code folding when a comment or blank line precedes an indented sectioning command GitOrigin-RevId: 2a955311c1ce073b2eb80fdfbf45d00705e22d69
This commit is contained in:
@@ -111,6 +111,20 @@ export const LaTeXLanguage = LRLanguage.define({
|
||||
if (sibling?.type.is(termsModule.NewLine)) {
|
||||
return { from: content!.from, to: sibling.from }
|
||||
}
|
||||
if (sibling?.type.is(termsModule.Comment)) {
|
||||
// A trailing comment line (e.g. `%`) before an indented
|
||||
// sectioning command should be included in the fold, but the
|
||||
// sectioning command itself should still appear on its own
|
||||
// line. The Comment node consumes its trailing newline, so
|
||||
// end the fold one position before the Comment ends.
|
||||
return { from: content!.from, to: sibling.to - 1 }
|
||||
}
|
||||
if (sibling?.type.is(termsModule.BlankLine)) {
|
||||
// Blank line(s) between previous content and an indented
|
||||
// sectioning command: include all but the last newline in the
|
||||
// fold (mirroring the BlankLine handling below).
|
||||
return { from: content!.from, to: sibling.to - 1 }
|
||||
}
|
||||
}
|
||||
if (lastChild.type.is(termsModule.BlankLine)) {
|
||||
// HACK: BlankLine can contain any number above 2 of \n's.
|
||||
|
||||
Reference in New Issue
Block a user