✨ feat(vscode): 代码阅读侧栏右键菜单加「在 Finder 中显示」,按系统换成文件资源管理器 / 打开所在的文件夹

This commit is contained in:
cruldra committed 2026-10-08 07:17:26 +08:00
1 parent 430f98ade4
commit 5ce2e904f4
5 files changed
+121 -3

No files matched your search

@@ -0,0 +1,24 @@
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<void> {
if (!node)
return // 只挂在侧栏的行上,别处调用没有目标
await commands.executeCommand('revealFileInOS', node.uri)
}
export function registerRevealCommands(): Disposable {
return Disposable.from(...REVEAL_COMMANDS.map(id => commands.registerCommand(id, revealInOS)))
}