#247 - Fix front matter highlighting

This commit is contained in:
Elio Struyf
2022-02-13 09:38:06 -08:00
parent a1dbda0b23
commit 0decd84f7f
2 changed files with 9 additions and 4 deletions

View File

@@ -19,6 +19,7 @@
### 🐞 Fixes
- [#247](https://github.com/estruyf/vscode-front-matter/issues/247): Fix the front matter highlighting in markdown documents
## [6.0.0] - 2022-01-25 - [Release Notes](https://beta.frontmatter.codes/updates/v6.0.0)

View File

@@ -15,10 +15,6 @@ export class MarkdownFoldingProvider implements FoldingRangeProvider {
const range = MarkdownFoldingProvider.getFrontMatterRange(document);
if (range) {
MarkdownFoldingProvider.start = null;
MarkdownFoldingProvider.end = null;
MarkdownFoldingProvider.endLine = null;
MarkdownFoldingProvider.triggerHighlighting();
ranges.push(new FoldingRange(range.start.line, range.end.line, FoldingRangeKind.Region));
@@ -65,16 +61,24 @@ export class MarkdownFoldingProvider implements FoldingRangeProvider {
let start = null;
let end = null;
let endLine = null;
MarkdownFoldingProvider.start = null;
MarkdownFoldingProvider.end = null;
MarkdownFoldingProvider.endLine = null;
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (line.startsWith(lineStart) || line.startsWith(lineEnd)) {
if (i === 0 && start === null) {
start = i;
MarkdownFoldingProvider.start = start;
} else if (start !== null && end === null) {
end = i;
endLine = line.length;
MarkdownFoldingProvider.end = end;
MarkdownFoldingProvider.endLine = endLine;
MarkdownFoldingProvider.triggerHighlighting();
return new Range(new Position(start, 0), new Position(end, endLine));