Skip to content

Feature Request: Support opening .code-workspace files instead of folders for VS Code/Cursor #77

@Stormix

Description

@Stormix

Small disclaimer: AI was used to polish the description of this issue from my rough notes

Summary

First of all, thanks for this tool, it’s become part of our daily workflow and has been working really well for us 🙌

When using gtr editor or gtr create --editor, gtr currently opens the worktree directory directly in the editor. However, editors like VS Code and Cursor support .code-workspace files, which allow defining multi-root workspaces, editor settings, and recommended extensions.

Context

At work, we rely heavily on .code-workspace files to ensure projects open with the correct structure and configuration. Most of our repositories already include one at the root for this reason.

Problem

Even when a .code-workspace file is present, gtr always opens the folder itself. This means we have to manually open the workspace file every time after the editor launches, which breaks the otherwise smooth workflow.

Proposed Solution

Add support for opening workspace files when launching an editor:

  1. Config option
    Allow specifying a workspace file via configuration, e.g. gtr.editor.workspace (or defaults.workspace in .gtrconfig), resolved relative to the worktree root.

  2. Auto-detect fallback
    If no config is set, automatically look for a *.code-workspace file in the worktree root and use it if found.

Example

# Configure a specific workspace file
git gtr config set gtr.editor.workspace "project.code-workspace"

# Or in .gtrconfig
[defaults]
    workspace = project.code-workspace

When opening a worktree, the editor would receive the workspace file path instead of the folder, for example:

  • cursor project.code-workspace instead of cursor /path/to/worktree

Notes / Constraints

  • Only applies to editors that support workspace files (VS Code, Cursor)
  • Workspace paths are resolved relative to the worktree root
  • Falls back to opening the folder if the workspace file doesn’t exist
  • Likely requires changes in:
    - adapters/editor/cursor.sh
    - adapters/editor/vscode.sh

Affected Commands

  • git gtr create --editor
  • git gtr editor <id>

Next Steps

If this is something the team would be interested in, I’m happy to open a PR in the next few days to implement it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions