import type { FileNode } from './fileTree' import { commands, Disposable } from 'vscode' /** * 在系统的文件管理器里显示这一行,菜单上的字跟 VS Code 自带资源管理器一样按系统叫: * macOS「在 Finder 中显示」、Windows「在文件资源管理器中显示」、Linux「打开所在的文件夹」。 * 做的事一样,分成三个命令只为菜单上写对字(package.json 按 `isMac` / `isWindows` / `isLinux` 挑)。 */ const REVEAL_COMMANDS = [ 'superpowers.codeReader.revealInFinder', 'superpowers.codeReader.revealInFileExplorer', 'superpowers.codeReader.openContainingFolder', ] /** 交给 VS Code 自带的 `revealFileInOS`:文件是打开所在文件夹并选中它,文件夹是在上一层里选中它。 */ async function revealInOS(node: FileNode | undefined): Promise { if (!node) return // 只挂在侧栏的行上,别处调用没有目标 await commands.executeCommand('revealFileInOS', node.uri) } export function registerRevealCommands(): Disposable { return Disposable.from(...REVEAL_COMMANDS.map(id => commands.registerCommand(id, revealInOS))) }