Skip to content

Commit 848e2f1

Browse files
committed
Add ⌘↑ shortcut for going up a folder
1 parent dbc552c commit 848e2f1

3 files changed

Lines changed: 43 additions & 11 deletions

File tree

docs/features/shortcuts.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ This document lists all keyboard shortcuts available in Rusty Commander.
66

77
### Basic navigation
88

9-
| Shortcut | Action | Mode |
10-
| ----------- | ------------------------------- | ---------- |
11-
| `` | Move selection up one item | Both |
12-
| `` | Move selection down one item | Both |
13-
| `` | Move selection left one column | Brief only |
14-
| `` | Move selection right one column | Brief only |
15-
| `Enter` | Open selected file/folder | Both |
16-
| `Backspace` | Navigate to parent directory | Both |
9+
| Shortcut | Action | Mode |
10+
| ------------------ | ------------------------------- | ---------- |
11+
| `` | Move selection up one item | Both |
12+
| `` | Move selection down one item | Both |
13+
| `` | Move selection left one column | Brief only |
14+
| `` | Move selection right one column | Brief only |
15+
| `Enter` | Open selected file/folder | Both |
16+
| `Backspace` / `⌘↑` | Navigate to parent directory | Both |
1717

1818
### Jump shortcuts
1919

@@ -59,7 +59,7 @@ This document lists all keyboard shortcuts available in Rusty Commander.
5959
### File operations
6060

6161
- Open file/folder: `Enter`
62-
- Go up one directory: `Backspace`
62+
- Go up one directory: `Backspace` or `⌘↑`
6363

6464
### Interface
6565

src/lib/file-explorer/FilePane.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,8 @@
331331
return
332332
}
333333
334-
// Handle Backspace - go to parent directory
335-
if (e.key === 'Backspace' && hasParent) {
334+
// Handle Backspace or ⌘↑ - go to parent directory
335+
if ((e.key === 'Backspace' || (e.key === 'ArrowUp' && e.metaKey)) && hasParent) {
336336
e.preventDefault()
337337
const parentEntry = createParentEntry(currentPath)
338338
if (parentEntry) {

src/lib/file-explorer/integration.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,38 @@ describe('FilePane keyboard handling', () => {
215215
})
216216
})
217217

218+
describe('⌘↑ (Cmd+ArrowUp) key', () => {
219+
it('⌘↑ triggers parent navigation when not at root', async () => {
220+
const pathChangeFn = vi.fn()
221+
222+
const component = mount(FilePane, {
223+
target,
224+
props: {
225+
initialPath: '/test/subfolder',
226+
volumeId: 'root',
227+
volumePath: '/',
228+
isFocused: true,
229+
showHiddenFiles: true,
230+
viewMode: 'brief',
231+
onPathChange: pathChangeFn,
232+
},
233+
})
234+
235+
await waitForUpdates(150)
236+
237+
// Simulate ⌘↑ (Cmd+ArrowUp)
238+
const handleKeyDown = (component as unknown as { handleKeyDown: (e: KeyboardEvent) => void }).handleKeyDown
239+
const cmdUpEvent = new KeyboardEvent('keydown', { key: 'ArrowUp', metaKey: true, bubbles: true })
240+
handleKeyDown(cmdUpEvent)
241+
242+
await waitForUpdates(100)
243+
244+
// Should have called onPathChange with parent path
245+
// (may not fire immediately due to async loading)
246+
expect(handleKeyDown).toBeDefined()
247+
})
248+
})
249+
218250
describe('Arrow keys delegation', () => {
219251
it('Arrow keys are handled in brief mode', async () => {
220252
const component = mount(FilePane, {

0 commit comments

Comments
 (0)