vscode: migrate settings.json writer to full hujson AST manipulation
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 58/100
Hướng nghiên cứu
Bắt đầu với cmd/modern/root/open/jsonc.go và cmd/modern/root/open/vscode.go để theo dõi việc phân tích cú pháp hujson hiện tại, quá trình xây dựng profile và các đường dẫn cập nhật. Mở rộng cmd/modern/root/open/jsonc_test.go, bao gồm TestApplyJSONCSettingsUpdates_PreservesComments, cho các chú thích liền kề với add và theo từng kết nối. Hoàn thành khi các cập nhật AST hujson trực tiếp giữ nguyên chú thích, thứ tự và các trường không liên quan đối với profile mới và hiện có.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Background
PR #688 added sqlcmd open vscode, which writes the user's settings.json to register a connection profile. The original implementation stripped JSONC comments and trailing commas, marshaled fresh JSON, and saved the user's original to a .sqlcmd-backup file. dlevy flagged that this clobbers the backup on every subsequent run (e.g. creating a second container loses the first backup) and silently destroys hand-authored comments.
PR #688 follow-up commit replaced the strip-and-marshal round trip with github.com/tailscale/hujson. We now parse the original AST and apply an RFC 6902 patch that touches only the two keys we own (mssql.connections, mssql.connectionGroups). Comments, trailing commas, and unrelated user keys round-trip untouched on replace operations, and the .sqlcmd-backup file is no longer needed.
Remaining limitation
hujson's Patch "add" operation (used when the document doesn't yet have an mssql.connections key) can blank a comment immediately adjacent to the insertion point. Unrelated keys are preserved; only a comment line at the insertion site is affected. This is a one-time event per settings.json (subsequent runs use the "replace" path, which fully preserves comments).
Additionally, createProfile / updateOrAddProfile in cmd/modern/root/open/vscode.go operate on map[string]interface{} for the connection array itself. This means per-connection comments inside mssql.connections[*] are not preserved when sqlcmd updates an existing profile.
Proposed work
Refactor cmd/modern/root/open/jsonc.go and the profile-construction helpers to operate directly on hujson.Value AST nodes instead of decoded maps. Specifically:
- Walk the parsed root
*hujson.Objectto findmssql.connectionsandmssql.connectionGroupsmembers, mutating theirValuein place rather than going through a JSON patch. - For the array of profiles, locate the existing profile member by
idand rewrite its*hujson.Objectfields one at a time, leaving member ordering and surrounding extras intact. - When inserting a new profile or a new top-level key, set
ObjectMember.Name.BeforeExtraexplicitly so the preceding comment isn't absorbed by hujson's leading-comment extraction.
Verification
The round-trip test in cmd/modern/root/open/jsonc_test.go (TestApplyJSONCSettingsUpdates_PreservesComments) should be extended to cover the add-comment-adjacent case, and a new test should verify per-connection comments inside the mssql.connections array survive an update to an existing profile.
References
- PR: #688
- Related review thread: https://github.com/microsoft/go-sqlcmd/pull/688#discussion_r3325235606
- hujson patch semantics: https://github.com/tailscale/hujson/blob/main/patch.go
- Ngôn ngữ chính
- Go
- Star
- 601
- Fork
- 91
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/go-sqlcmd
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Fix CVEs in Version v1.10.0Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
-
":Help" command not workingĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
-
-r discards the "Msg N, Level N, State N" error header — errors on stderr lose message number and line infoCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
Tất cả issue của microsoft/go-sqlcmd
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
prime-radiant-inc/evener#3873 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
pion/interceptor#479 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
yetone/magpie#1035 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Project submission: 5diveĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
slavakurilyak/awesome-ai-agents#710 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`renderLinkedIssues` overshoots its byte budget: unresolved and omitted lists are never boundedĐang mởagent-butler-finding agent-research-recommend bug ready-for-agent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
jordansmall/spindrift#4614 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày