Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added editors/vscode/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions editors/vscode/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion editors/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
"name": "logic-md-vscode",
"displayName": "LOGIC.md",
"description": "Syntax highlighting and validation for LOGIC.md reasoning specifications",
"version": "0.1.1",
"version": "0.1.2",
"publisher": "singlesourceai",
"license": "MIT",
"icon": "icon.png",
"repository": {
"type": "git",
"url": "https://github.com/SingularityAI-Dev/logic-md"
Expand Down
13 changes: 10 additions & 3 deletions editors/vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,16 @@ function validateDocument(doc: vscode.TextDocument): void {
const text = doc.getText();
const lines = text.split("\n");

// Check for frontmatter delimiters
const frontmatterStart = text.search(/^---/m);
const frontmatterEnd = text.search(/^---/m, frontmatterStart + 1);
// Check for frontmatter delimiters.
// NOTE: String.prototype.search() ignores any second argument, so we use a /g regex
// with repeated .exec() calls to find the opening and closing --- delimiters.
// Frontmatter must be the very first line of the document; stray --- blocks later
// in the file (e.g. markdown horizontal rules) must not be treated as frontmatter.
const fmRegex = /^---\s*$/gm;
const firstMatch = fmRegex.exec(text);
const frontmatterStart = firstMatch && firstMatch.index === 0 ? 0 : -1;
const secondMatch = frontmatterStart === 0 ? fmRegex.exec(text) : null;
const frontmatterEnd = secondMatch ? secondMatch.index : -1;

if (frontmatterStart === -1) {
const range = new vscode.Range(0, 0, 0, 0);
Expand Down