|
354 | 354 | return false |
355 | 355 | } |
356 | 356 |
|
357 | | - // Handle cancel loading for left pane - navigate back in history or to home |
358 | | - function handleLeftCancelLoading() { |
359 | | - if (canGoBack(leftHistory)) { |
360 | | - void handleNavigationAction('back') |
| 357 | + // Handle cancel loading for left pane - reload current history entry (the folder we were in before the slow load) |
| 358 | + // The slow-loading folder was never added to history, so current entry is already correct. |
| 359 | + function handleLeftCancelLoading(selectName?: string) { |
| 360 | + const entry = getCurrentEntry(leftHistory) |
| 361 | +
|
| 362 | + if (entry.volumeId === 'network') { |
| 363 | + leftPath = entry.path |
| 364 | + leftVolumeId = 'network' |
| 365 | + void saveAppStatus({ leftVolumeId: 'network', leftPath: entry.path }) |
| 366 | + // eslint-disable-next-line @typescript-eslint/no-unsafe-call |
| 367 | + leftPaneRef?.setNetworkHost?.(entry.networkHost ?? null) |
361 | 368 | } else { |
362 | | - // Navigate to home |
363 | | - leftPath = '~' |
364 | | - leftVolumeId = DEFAULT_VOLUME_ID |
365 | | - void saveAppStatus({ leftPath: '~', leftVolumeId: DEFAULT_VOLUME_ID }) |
366 | | - } |
367 | | - } |
368 | | -
|
369 | | - // Handle cancel loading for right pane - navigate back in history or to home |
370 | | - function handleRightCancelLoading() { |
371 | | - if (canGoBack(rightHistory)) { |
372 | | - // Need to handle this specially since handleNavigationAction uses focusedPane |
373 | | - const history = rightHistory |
374 | | - const newHistory = back(history) |
375 | | - const targetEntry = getCurrentEntry(newHistory) |
376 | | -
|
377 | | - if (targetEntry.volumeId === 'network') { |
378 | | - rightHistory = newHistory |
379 | | - rightPath = targetEntry.path |
380 | | - rightVolumeId = 'network' |
381 | | - void saveAppStatus({ rightVolumeId: 'network', rightPath: targetEntry.path }) |
382 | | - // eslint-disable-next-line @typescript-eslint/no-unsafe-call |
383 | | - rightPaneRef?.setNetworkHost?.(targetEntry.networkHost ?? null) |
384 | | - } else { |
385 | | - void resolveValidPath(targetEntry.path).then((resolvedPath) => { |
386 | | - if (resolvedPath !== null) { |
387 | | - rightHistory = newHistory |
388 | | - rightPath = resolvedPath |
389 | | - if (targetEntry.volumeId !== rightVolumeId) { |
390 | | - rightVolumeId = targetEntry.volumeId |
391 | | - void saveAppStatus({ rightVolumeId: targetEntry.volumeId, rightPath: resolvedPath }) |
392 | | - } else { |
393 | | - void saveAppStatus({ rightPath: resolvedPath }) |
394 | | - } |
395 | | - void saveLastUsedPathForVolume(targetEntry.volumeId, resolvedPath) |
| 369 | + void resolveValidPath(entry.path).then((resolvedPath) => { |
| 370 | + if (resolvedPath !== null) { |
| 371 | + leftPath = resolvedPath |
| 372 | + if (entry.volumeId !== leftVolumeId) { |
| 373 | + leftVolumeId = entry.volumeId |
| 374 | + void saveAppStatus({ leftVolumeId: entry.volumeId, leftPath: resolvedPath }) |
| 375 | + } else { |
| 376 | + void saveAppStatus({ leftPath: resolvedPath }) |
396 | 377 | } |
397 | | - }) |
398 | | - } |
| 378 | + // Navigate with selection to restore cursor to the folder we tried to enter |
| 379 | + // eslint-disable-next-line @typescript-eslint/no-unsafe-call |
| 380 | + leftPaneRef?.navigateToPath?.(resolvedPath, selectName) |
| 381 | + } else { |
| 382 | + // Path doesn't exist, fall back to home |
| 383 | + leftPath = '~' |
| 384 | + leftVolumeId = DEFAULT_VOLUME_ID |
| 385 | + void saveAppStatus({ leftPath: '~', leftVolumeId: DEFAULT_VOLUME_ID }) |
| 386 | + } |
| 387 | + }) |
| 388 | + } |
| 389 | + containerElement?.focus() |
| 390 | + } |
| 391 | +
|
| 392 | + // Handle cancel loading for right pane - reload current history entry (the folder we were in before the slow load) |
| 393 | + // The slow-loading folder was never added to history, so current entry is already correct. |
| 394 | + function handleRightCancelLoading(selectName?: string) { |
| 395 | + const entry = getCurrentEntry(rightHistory) |
| 396 | +
|
| 397 | + if (entry.volumeId === 'network') { |
| 398 | + rightPath = entry.path |
| 399 | + rightVolumeId = 'network' |
| 400 | + void saveAppStatus({ rightVolumeId: 'network', rightPath: entry.path }) |
| 401 | + // eslint-disable-next-line @typescript-eslint/no-unsafe-call |
| 402 | + rightPaneRef?.setNetworkHost?.(entry.networkHost ?? null) |
399 | 403 | } else { |
400 | | - // Navigate to home |
401 | | - rightPath = '~' |
402 | | - rightVolumeId = DEFAULT_VOLUME_ID |
403 | | - void saveAppStatus({ rightPath: '~', rightVolumeId: DEFAULT_VOLUME_ID }) |
| 404 | + void resolveValidPath(entry.path).then((resolvedPath) => { |
| 405 | + if (resolvedPath !== null) { |
| 406 | + rightPath = resolvedPath |
| 407 | + if (entry.volumeId !== rightVolumeId) { |
| 408 | + rightVolumeId = entry.volumeId |
| 409 | + void saveAppStatus({ rightVolumeId: entry.volumeId, rightPath: resolvedPath }) |
| 410 | + } else { |
| 411 | + void saveAppStatus({ rightPath: resolvedPath }) |
| 412 | + } |
| 413 | + // Navigate with selection to restore cursor to the folder we tried to enter |
| 414 | + // eslint-disable-next-line @typescript-eslint/no-unsafe-call |
| 415 | + rightPaneRef?.navigateToPath?.(resolvedPath, selectName) |
| 416 | + } else { |
| 417 | + // Path doesn't exist, fall back to home |
| 418 | + rightPath = '~' |
| 419 | + rightVolumeId = DEFAULT_VOLUME_ID |
| 420 | + void saveAppStatus({ rightPath: '~', rightVolumeId: DEFAULT_VOLUME_ID }) |
| 421 | + } |
| 422 | + }) |
404 | 423 | } |
405 | 424 | containerElement?.focus() |
406 | 425 | } |
|
0 commit comments