Skip to content

fix(migrate): preserve comments in existing editor JSONC configs#1956

Merged
fengmk2 merged 2 commits into
mainfrom
fix/preserve-editor-jsonc-comments
Jun 26, 2026
Merged

fix(migrate): preserve comments in existing editor JSONC configs#1956
fengmk2 merged 2 commits into
mainfrom
fix/preserve-editor-jsonc-comments

Conversation

@fengmk2

@fengmk2 fengmk2 commented Jun 26, 2026

Copy link
Copy Markdown
Member

Problem

vp migrate dropped comments from existing .vscode / .zed JSON(C) files. The merge parsed the file into an object and re-serialized it with JSON.stringify, losing comments, key order, and trailing commas.

Fix

Patch the original text with jsonc-parser (modify + applyEdits) instead of serializing a merged object. Only missing keys/branches are inserted; existing values, comments, and formatting are left untouched. Extension recommendations are appended without rebuilding the array, and a no-op merge no longer rewrites the file.

Tests

  • Strengthened editor.spec.ts to assert comment text survives, plus cases for nested comments, existing-values-win, trailing commas, extension dedup, idempotence, and Zed.
  • Added snap test migration-preserve-editor-jsonc-comments.

Merging editor settings re-serialized the parsed object with JSON.stringify,
dropping comments, key order, and trailing commas from existing .vscode/.zed
files. Patch the original text with jsonc-parser instead so only missing keys
are inserted and existing content is left untouched.
@fengmk2 fengmk2 self-assigned this Jun 26, 2026
@netlify

netlify Bot commented Jun 26, 2026

Copy link
Copy Markdown

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit 92eb9a6
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a3e8ce874e8f6000844e167

@fengmk2

fengmk2 commented Jun 26, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 2a1097f56f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

- Share formatting detection via json.ts detectFormattingOptions
- Extract applyJsoncEdit helper for the modify/applyEdits pattern
- Use a Set for existing recommendation lookup
- Ignore the JSONC snap-test fixtures in fmt so comments/trailing commas stay
@fengmk2 fengmk2 marked this pull request as ready for review June 26, 2026 14:30
@fengmk2 fengmk2 added test: e2e Auto run e2e tests test: create-e2e Run `vp create` e2e tests labels Jun 26, 2026
@fengmk2 fengmk2 merged commit f3a3374 into main Jun 26, 2026
122 of 141 checks passed
@fengmk2 fengmk2 deleted the fix/preserve-editor-jsonc-comments branch June 26, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test: create-e2e Run `vp create` e2e tests test: e2e Auto run e2e tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants