Skip to content

Commit 53b5895

Browse files
committed
Bugfix for #131
Obsidian introduced breaking changes around File Explorer JS structure which prevented this custom-sort plugin from working. - fix backward compatible with versions earlier that 1.5.4 - version bump before release
1 parent 9f4008c commit 53b5895

File tree

5 files changed

+7
-10
lines changed

5 files changed

+7
-10
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
| :exclamation: For users of Obsidian insider build versions (1.5.4 and up)|
2-
|----|
3-
| 1.5.4 insider build of Obsidian introduced breaking changes in JS code of File Explorer which prevents this custom-sort plugin from working. Please refrain from updating Obsidian until the code of custom-sort is updated. |
4-
51
> > This is a simple version of README which highlights the **basic scenario and most commonly used feature**
62
>
73
> The [long and much more detailed advanced-README.md is here](https://github.com/SebastianMC/obsidian-custom-sort/blob/master/docs/advanced-README.md)

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "custom-sort",
33
"name": "Custom File Explorer sorting",
4-
"version": "2.1.5",
4+
"version": "2.1.7",
55
"minAppVersion": "0.16.2",
66
"description": "Allows for manual and automatic, config-driven reordering and sorting of files and folders in File Explorer",
77
"author": "SebastianMC",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-custom-sort",
3-
"version": "2.1.5",
3+
"version": "2.1.7",
44
"description": "Custom Sort plugin for Obsidian (https://obsidian.md)",
55
"main": "main.js",
66
"scripts": {

src/custom-sort/custom-sort.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ export const determineBookmarksOrderIfNeeded = (folderItems: Array<FolderItemFor
685685
}
686686

687687
export const folderSort = function (sortingSpec: CustomSortSpec, ctx: ProcessingContext) {
688-
let fileExplorer = this.fileExplorer
688+
let fileExplorerView = this.fileExplorer ?? this.view // this.view replaces the former since 1.5.4 insider build
689689

690690
// shallow copy of groups and expand folder-specific macros on them
691691
sortingSpec.groupsShadow = sortingSpec.groups?.map((group) => Object.assign({} as CustomSortGroup, group))
@@ -710,12 +710,12 @@ export const folderSort = function (sortingSpec: CustomSortSpec, ctx: Processing
710710
determineBookmarksOrderIfNeeded(folderItems, sortingSpec, ctx.bookmarksPluginInstance)
711711
}
712712

713-
const comparator: SorterFn = getComparator(sortingSpec, fileExplorer.sortOrder)
713+
const comparator: SorterFn = getComparator(sortingSpec, fileExplorerView.sortOrder)
714714

715715
folderItems.sort(comparator)
716716

717717
const items = folderItems
718-
.map((item: FolderItemForSorting) => fileExplorer.fileItems[item.path])
718+
.map((item: FolderItemForSorting) => fileExplorerView.fileItems[item.path])
719719

720720
if (requireApiVersion && requireApiVersion("0.15.0")) {
721721
this.vChildren.setChildren(items);

versions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@
3939
"2.1.2": "0.16.2",
4040
"2.1.3": "0.16.2",
4141
"2.1.4": "0.16.2",
42-
"2.1.5": "0.16.2"
42+
"2.1.5": "0.16.2",
43+
"2.1.7": "0.16.2"
4344
}

0 commit comments

Comments
 (0)