feat(vscode): PyCharm 启动命令可配置(支持 ~/绝对路径),抽 expandTilde 复用

GUI 启动的 VS Code 扩展进程 PATH 常不含 JetBrains 启动器,裸 pycharm 易 ENOENT。
新增设置 pycharmCommand(默认 pycharm),贯穿 store/settings handler/messages/
KanbanPanel 与 webview,「钩子」分组在选 PyCharm 时显示「PyCharm 启动命令」输入框。
handleOpenWorktree 用该命令并经 expandTilde 展开 ~。expandTilde 从 resolveWorktreePath
抽出共用。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-24 05:29:19 +08:00
co-authored by Claude Opus 4.7
parent cacc60eb0e
commit 02b0aca891
10 changed files with 84 additions and 9 deletions
+14
View File
@@ -100,6 +100,13 @@ export interface Settings {
* `'vscode'` (default) opens a new VS Code window.
*/
worktreeOpenWith: 'vscode' | 'pycharm'
/**
* Command used to launch PyCharm when `worktreeOpenWith === 'pycharm'`.
* A bare name relies on PATH, which a GUI-launched VS Code often lacks, so
* an absolute path (or a `~`-prefixed one) is the reliable choice. Empty
* means "use the default `pycharm`".
*/
pycharmCommand: string
/**
* Path to a user-provided shell script that runs *after* the extension
* creates a worktree via `git worktree add`. Empty string means use the
@@ -173,6 +180,7 @@ function defaults(ctx: ExtensionContext): Settings {
autoBuildBranch: '',
worktreeDirectory: '~/Sources/worktree/$project_name/$feature_name',
worktreeOpenWith: 'vscode',
pycharmCommand: 'pycharm',
worktreePostCreateScript: '',
worktreePreRemoveScript: '',
implTabPreCreateScript: '',
@@ -226,6 +234,11 @@ export function getSettings(ctx: ExtensionContext): Settings {
const worktreeOpenWith = stored.worktreeOpenWith === 'pycharm' || stored.worktreeOpenWith === 'vscode'
? stored.worktreeOpenWith
: base.worktreeOpenWith
// pycharm launcher command: blank means "use the default `pycharm`", so fall
// back to base rather than preserving an empty string.
const pycharmCommand = typeof stored.pycharmCommand === 'string' && stored.pycharmCommand.length > 0
? stored.pycharmCommand
: base.pycharmCommand
// worktree hook script paths: '' is meaningful (= "use default
// .spx/worktree-*.sh"), so don't coerce. Non-string legacy values fall
// back to ''. The hook runner resolves '' to the default at execution
@@ -266,6 +279,7 @@ export function getSettings(ctx: ExtensionContext): Settings {
autoBuildBranch,
worktreeDirectory,
worktreeOpenWith,
pycharmCommand,
worktreePostCreateScript,
worktreePreRemoveScript,
implTabPreCreateScript,