Documentation
¶
Overview ¶
Package vscodeworkspace builds `.code-workspace` JSON documents from the gitmap repo database. Output matches the schema VS Code produces via "File → Save Workspace As…", so a workspace file emitted by gitmap can be hand-edited and re-emitted without surprising diffs.
The builder is intentionally pure: it takes plain folder tuples and returns bytes. Disk I/O lives in write.go; CLI flag parsing and DB access live in the cmd package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Encode ¶
Encode renders ws as tab-indented JSON with a trailing newline, matching the byte shape VS Code itself emits.
func WriteAtomic ¶
WriteAtomic encodes ws and commits it to outPath via temp-file + rename. Same atomic-rename pattern vscodepm.Sync uses for projects.json — partial writes are never observed, even if the process is killed mid-flush.
Types ¶
type Folder ¶
Folder is one entry in the workspace's "folders" array. Name is optional in the VS Code schema but always populated by gitmap so the sidebar shows the repo name (not the basename of the on-disk folder, which may have been flattened by clone-next).
func Relativize ¶
Relativize rewrites each folder's Path to be relative to baseDir (the directory the workspace file lives in). Paths that cannot be expressed relatively (different volume on Windows) are left as absolute and an error is returned so the caller can surface the fallback.
type Workspace ¶
type Workspace struct {
Folders []Folder `json:"folders"`
Settings map[string]any `json:"settings"`
}
Workspace is the top-level `.code-workspace` document. Settings is always emitted as `{}` so VS Code's first-open experience matches a freshly-saved workspace file.
func Build ¶
Build assembles a Workspace from the supplied folder tuples, dropping duplicates by path and sorting by Name for diff stability. Path comparison is case-folded on Windows via filepath.Clean + strings.EqualFold, but we keep the original casing in the output to preserve user-visible spelling.