mirror of
https://github.com/wavetermdev/waveterm
synced 2026-05-05 22:48:48 +00:00
Back Arrow goes back to existing parent (#979)
This change makes the preview back arrow take you back to a parent directory that already exists if you are stuck in a bad state. this prevents it from opening a directory that doesn't exist as a file, which can happen if you use the typeahead to reach a file that doesn't exist inside a directory that doesn't exist.
This commit is contained in:
parent
92fd371fc9
commit
0ca1dbfbcc
1 changed files with 12 additions and 3 deletions
|
|
@ -509,8 +509,12 @@ export class PreviewModel implements ViewModel {
|
|||
}
|
||||
}
|
||||
|
||||
async goParentDirectory() {
|
||||
const fileInfo = await globalStore.get(this.statFile);
|
||||
async goParentDirectory({ fileInfo = null }: { fileInfo?: FileInfo | null }) {
|
||||
// optional parameter needed for recursive case
|
||||
const defaultFileInfo = await globalStore.get(this.statFile);
|
||||
if (fileInfo === null) {
|
||||
fileInfo = defaultFileInfo;
|
||||
}
|
||||
if (fileInfo == null) {
|
||||
this.updateOpenFileModalAndError(false);
|
||||
return true;
|
||||
|
|
@ -520,6 +524,11 @@ export class PreviewModel implements ViewModel {
|
|||
const newFileInfo = await RpcApi.RemoteFileJoinCommand(WindowRpcClient, [fileInfo.path, ".."], {
|
||||
route: makeConnRoute(conn),
|
||||
});
|
||||
if (newFileInfo.path != "" && newFileInfo.notfound) {
|
||||
console.log("does not exist, ", newFileInfo.path);
|
||||
this.goParentDirectory({ fileInfo: newFileInfo });
|
||||
return;
|
||||
}
|
||||
console.log(newFileInfo.path);
|
||||
this.updateOpenFileModalAndError(false);
|
||||
this.goHistory(newFileInfo.path);
|
||||
|
|
@ -694,7 +703,7 @@ export class PreviewModel implements ViewModel {
|
|||
}
|
||||
if (keyutil.checkKeyPressed(e, "Cmd:ArrowUp")) {
|
||||
// handle up directory
|
||||
this.goParentDirectory();
|
||||
this.goParentDirectory({});
|
||||
return true;
|
||||
}
|
||||
const openModalOpen = globalStore.get(this.openFileModal);
|
||||
|
|
|
|||
Loading…
Reference in a new issue