Skip to content

Commit d59b1af

Browse files
committed
#137 - Impose File Explorer refresh with standard sorting when the plugin gets disabled
1 parent 8ed1840 commit d59b1af

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/main.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,17 @@ export default class CustomSortPlugin extends Plugin {
616616
// For the idea of monkey-patching credits go to https://github.com/nothingislost/obsidian-bartender
617617
patchFileExplorerFolder(patchableFileExplorer?: FileExplorerView): boolean {
618618
let plugin = this;
619+
const requestStandardObsidianSortAfter = (patchUninstaller: MonkeyAroundUninstaller|undefined) => {
620+
return () => {
621+
if (patchUninstaller) patchUninstaller()
622+
623+
const fileExplorerView: FileExplorerView | undefined = this.checkFileExplorerIsAvailableAndPatchable(false)
624+
if (fileExplorerView) {
625+
fileExplorerView.requestSort()
626+
}
627+
}
628+
}
629+
619630
// patching file explorer might fail here because of various non-error reasons.
620631
// That's why not showing and not logging error message here
621632
patchableFileExplorer = patchableFileExplorer ?? this.checkFileExplorerIsAvailableAndPatchable(false)
@@ -643,7 +654,7 @@ export default class CustomSortPlugin extends Plugin {
643654
};
644655
}
645656
})
646-
this.register(uninstallerOfFolderSortFunctionWrapper)
657+
this.register(requestStandardObsidianSortAfter(uninstallerOfFolderSortFunctionWrapper))
647658
return true
648659
} else {
649660
// Up to Obsidian 1.6.0
@@ -671,7 +682,7 @@ export default class CustomSortPlugin extends Plugin {
671682
};
672683
}
673684
})
674-
this.register(uninstallerOfFolderSortFunctionWrapper)
685+
this.register(requestStandardObsidianSortAfter(uninstallerOfFolderSortFunctionWrapper))
675686
return true
676687
}
677688
} else {

0 commit comments

Comments
 (0)