| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
Adds a Notepad++-pack feature that automatically pretty-prints JSON when pasting into any editor buffer (including untitled scratch tabs), with a pure core function and unit tests to ensure only valid JSON containers are transformed.
Changes:
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file| File | Description |
|---|---|
| extensions/levelcode-npp-pack/test/jsonBeautify.test.js | Adds unit tests for JSON paste analysis/beautification logic. |
| extensions/levelcode-npp-pack/package.json | Adds configuration schema for JSON beautify-on-paste settings. |
| extensions/levelcode-npp-pack/jsonPaste.js | Implements the VS Code paste provider glue for beautifying JSON on paste. |
| extensions/levelcode-npp-pack/jsonBeautify.js | Adds pure logic to detect/format beautifiable JSON pastes with a size guard. |
| extensions/levelcode-npp-pack/extension.js | Wires the new JSON paste feature into extension activation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
| test('honors the size guard (parses nothing past maxBytes)', () => { | ||
| const r = analyzePaste('[1,2,3,4,5]', { maxBytes: 4 }); | ||
| assert.strictEqual(r.beautify, false); | ||
| assert.strictEqual(r.reason, 'too-large'); | ||
| assert.ok(MAX_BYTES >= 1024 * 1024, 'default cap should be sizeable'); | ||
| }); |
Addresses the PR #27 review (Copilot). The guard is named/documented as a byte cap (MAX_BYTES / maxBytes) but checked `trimmed.length` — UTF-16 code units. For non-ASCII pastes that undercounts the real size (a CJK char is 1 code unit but 3 UTF-8 bytes), so a payload up to ~3× the intended cap could slip past and get parsed/stringified on paste, defeating the ext-host-stall protection. Switched the check to Buffer.byteLength(trimmed, 'utf8') so the cap means what its name says, and added a regression test: a JSON blob whose .length is under the cap but whose byte size is over it is now blocked (and still beautifies when the cap is raised above its byte size). Verified: 13 tests pass; a 58-code-unit / 158-byte payload is now too-large at maxBytes=100, where a .length guard would have parsed it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| Back | FazBrowse Home | New Git URL |
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.