Merge pull request #508 from Awesome-AI-Pedia/fix/504-windows-reveal
fix: preserve Windows Explorer reveal selection
This commit is contained in:
@@ -28,11 +28,10 @@ export function revealCommand(path: string, platform: NodeJS.Platform = process.
|
||||
switch (platform) {
|
||||
case 'darwin':
|
||||
return { command: 'open', args: ['-R', path] }
|
||||
// `explorer /select,<path>` — the classic "show in folder" incantation.
|
||||
// Passed as separate argv entries (no shell); verify on Windows, with
|
||||
// `cmd /c start "" explorer.exe "/select,<path>"` as the fallback.
|
||||
// Explorer expects `/select,<path>` as one argument. Keep the spawn
|
||||
// shell-free: a command shell would reinterpret valid path characters.
|
||||
case 'win32':
|
||||
return { command: 'explorer.exe', args: ['/select,', path] }
|
||||
return { command: 'explorer.exe', args: [`/select,${path}`] }
|
||||
default: {
|
||||
const parent = parentOf(path)
|
||||
return { command: 'xdg-open', args: [parent ?? path] }
|
||||
|
||||
@@ -13,8 +13,11 @@ describe('revealCommand', () => {
|
||||
expect(revealCommand('/a/b.txt', 'darwin')).toEqual({ command: 'open', args: ['-R', '/a/b.txt'] })
|
||||
})
|
||||
|
||||
it('win32: `explorer /select,<path>` selects the file', () => {
|
||||
expect(revealCommand('C:\\a\\b.txt', 'win32')).toEqual({ command: 'explorer.exe', args: ['/select,', 'C:\\a\\b.txt'] })
|
||||
it('win32: passes /select,<path> as one shell-free Explorer argument', () => {
|
||||
expect(revealCommand('C:\\work\\two words\\a.txt', 'win32')).toEqual({
|
||||
command: 'explorer.exe',
|
||||
args: ['/select,C:\\work\\two words\\a.txt'],
|
||||
})
|
||||
})
|
||||
|
||||
it('linux: `xdg-open` opens the containing directory (no common select protocol)', () => {
|
||||
|
||||
Reference in New Issue
Block a user