✨ 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:
@@ -10,16 +10,21 @@ import { execFile } from 'node:child_process'
|
||||
import * as os from 'node:os'
|
||||
import * as path from 'node:path'
|
||||
|
||||
/**
|
||||
* 把开头的 `~` 展开为用户 home 目录。execFile 不走 shell,传给它的命令/路径
|
||||
* 里的 `~` 不会被展开,需要我们自己处理。
|
||||
*/
|
||||
export function expandTilde(p: string): string {
|
||||
return p.startsWith('~') ? path.join(os.homedir(), p.slice(1)) : p
|
||||
}
|
||||
|
||||
/**
|
||||
* 把存储的 worktreePath 解析成可用的绝对路径。三态合一:
|
||||
* 开头 `~` → 展开为 home(git/execFile 不走 shell,自己不展开 `~`,
|
||||
* 存量工单里可能存了带 `~` 的字面量);已是绝对 → 原样;
|
||||
* 开头 `~` → 展开为 home(存量工单里可能存了带 `~` 的字面量);已是绝对 → 原样;
|
||||
* 相对 → 拼到 workspaceRoot 下(旧的 .claude/worktrees/<hash> 方案)。
|
||||
*/
|
||||
export function resolveWorktreePath(stored: string, workspaceRoot: string): string {
|
||||
let p = stored
|
||||
if (p.startsWith('~'))
|
||||
p = path.join(os.homedir(), p.slice(1))
|
||||
const p = expandTilde(stored)
|
||||
return path.isAbsolute(p) ? p : path.join(workspaceRoot, p)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user