fix(vscode): frontmatter diagnostic + icon (v0.1.2)#31
fix(vscode): frontmatter diagnostic + icon (v0.1.2)#31SingleSourceStudios merged 2 commits intomainfrom
Conversation
📝 WalkthroughWalkthroughThe VS Code extension receives a minor version bump to 0.1.2, with an icon metadata field added to the manifest. Additionally, the frontmatter delimiter detection logic is refactored to use global multiline regex patterns with repeated exec() calls instead of String.search(). Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
editors/vscode/src/extension.ts (1)
87-93: Fix looks correct; consider guarding against non-leading frontmatter.The
/gm+ sequentialexec()approach correctly advanceslastIndexand resolves the originalsearch(regex, startIndex)bug. One pre-existing edge case worth noting (not introduced here):frontmatterStartisn't required to be0, so a document with a stray---block later in the file would be treated as frontmatter. If you want to tighten this, anchor the first match to the document start:Optional hardening
- const fmRegex = /^---\s*$/gm; - const firstMatch = fmRegex.exec(text); - const frontmatterStart = firstMatch ? firstMatch.index : -1; - const secondMatch = firstMatch ? fmRegex.exec(text) : null; - const frontmatterEnd = secondMatch ? secondMatch.index : -1; + const fmRegex = /^---\s*$/gm; + const firstMatch = fmRegex.exec(text); + // Frontmatter must be the very first line of the document. + const frontmatterStart = firstMatch && firstMatch.index === 0 ? 0 : -1; + const secondMatch = frontmatterStart === 0 ? fmRegex.exec(text) : null; + const frontmatterEnd = secondMatch ? secondMatch.index : -1;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@editors/vscode/src/extension.ts` around lines 87 - 93, The current code treats any `---` anywhere as frontmatter; guard by ensuring the first `fmRegex.exec(text)` match is at the document start (index 0) before treating it as frontmatter: after computing `firstMatch` (from `fmRegex.exec(text)`), check `firstMatch.index === 0` (or equivalently verify `frontmatterStart === 0`) and only then call `fmRegex.exec(text)` again to find the closing delimiter and set `frontmatterStart`/`frontmatterEnd`; otherwise treat as no frontmatter. This uses the existing symbols `fmRegex`, `firstMatch`, `frontmatterStart`, and the second `exec()` call.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@editors/vscode/src/extension.ts`:
- Around line 87-93: The current code treats any `---` anywhere as frontmatter;
guard by ensuring the first `fmRegex.exec(text)` match is at the document start
(index 0) before treating it as frontmatter: after computing `firstMatch` (from
`fmRegex.exec(text)`), check `firstMatch.index === 0` (or equivalently verify
`frontmatterStart === 0`) and only then call `fmRegex.exec(text)` again to find
the closing delimiter and set `frontmatterStart`/`frontmatterEnd`; otherwise
treat as no frontmatter. This uses the existing symbols `fmRegex`, `firstMatch`,
`frontmatterStart`, and the second `exec()` call.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 378033f0-c4d2-47d0-8b23-9d795937264b
⛔ Files ignored due to path filters (2)
editors/vscode/icon.pngis excluded by!**/*.pngeditors/vscode/package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (2)
editors/vscode/package.jsoneditors/vscode/src/extension.ts
Only treat --- as frontmatter when it appears at index 0. Prevents stray --- blocks later in the file (markdown horizontal rules) from being misidentified as frontmatter delimiters. Addresses CodeRabbit nitpick on #31.
What
Ships VSCode extension v0.1.2 (already published to Marketplace).
Changes
Bug fix: false-positive frontmatter diagnostic
String.prototype.search(regex, startIndex)silently ignores its second argument, sofrontmatterEndwas always equal tofrontmatterStart— the substring for the required-field check was empty, and every valid.logic.mdfile got three warnings (spec_version,name,reasoningmissing).Replaced with a
/g-flagged regex and two.exec()calls, which correctly advances past the first match vialastIndex. Also tightened the pattern to/^---\s*$/gmso only full-line---delimiters match.Icon
Added 256×256 marketplace icon (
editors/vscode/icon.png) referenced frompackage.json.Version
0.1.1→0.1.2. Already published viavsce publish.Test plan
hello-agent.logic.mdgenerated by@logic-md/cli init— no false-positive diagnostics after fix.Summary by cubic
Fixes frontmatter diagnostics for
.logic.mdby only treating---at the first line as frontmatter, removing false warnings forspec_version,name, andreasoningand ignoring later---blocks. Adds a 256×256 marketplace icon and bumps the VS Code extension to v0.1.2.Written for commit 5184ff8. Summary will update on new commits.
Summary by CodeRabbit
Chores
Bug Fixes